Avalos' Indie Blog

Artifact [0f1ea78243]
Login

Artifact 0f1ea78243adb34f94541729cf9a9052f1c2b3eb44d2c37076b31c742a7a6131:


resource_types:
  - name: rss
    type: docker-image
    source:
      repository: suhlig/concourse-rss-resource
      tag: latest
        
resources:
  - name: fossil
    type: rss
    source:
      url: https://fossil.avalos.me/avalos-indie-blog/timeline.rss?tag=trunk

jobs:
  - name: deploy-to-server
    serial: true
    plan:
      - get: fossil
        trigger: true
      - task: build
        config:
          platform: linux
          image_resource:
            type: docker-image
            source: { repository: debian, tag: buster-slim }
          params:
            HUGO_URL: https://github.com/gohugoio/hugo/releases/download/v0.73.0/hugo_0.73.0_Linux-64bit.tar.gz
            FOSSIL_URL: https://www.fossil-scm.org/fossil/uv/fossil-linux-x64-2.11.1.tar.gz
            FOSSIL_REPO_URL: https://fossil.avalos.me/avalos-indie-blog
          outputs:
            - name: static
          run:
            path: /bin/bash
            args:
              - -c
              - |
                apt-get update &&
                apt-get install -y wget &&
                wget -O fossil.tar.gz $FOSSIL_URL &&
                tar -xvf fossil.tar.gz &&
                wget -O hugo.tar.gz $HUGO_URL &&
                tar -xvf hugo.tar.gz &&
                ./fossil clone $FOSSIL_REPO_URL avalos-indie-blog.fossil &&
                ./fossil open avalos-indie-blog.fossil &&
                ./fossil close --force avalos-indie-blog.fossil &&
                ./hugo &&
                mv public static
      - task: deploy
        config:
          platform: linux
          image_resource:
            type: docker-image
            source: { repository: alpine, tag: edge }
          inputs:
            - name: static
          params:
            AWS_ACCESS_KEY_ID: ((AWS_ACCESS_KEY_ID))
            AWS_SECRET_ACCESS_KEY: ((AWS_SECRET_ACCESS_KEY))
            AWS_DEFAULT_REGION: ((AWS_DEFAULT_REGION))
            AWS_REGION: ((AWS_REGION))
            AWS_INSTANCE_ID: ((AWS_INSTANCE_ID))
            AWS_AVAILABILITY_ZONE: ((AWS_AVAILABILITY_ZONE))
            AWS_INSTANCE_OS_USER: ((AWS_INSTANCE_OS_USER))
          run:
            path: /bin/sh
            args:
              - -c
              - |
                apk update &&
                apk add rsync openssh-client aws-cli &&
                ssh-keygen -t rsa -f aws_key -q -N "" &&
                chmod 600 aws_key &&
                aws ec2-instance-connect send-ssh-public-key \
                  --region $AWS_REGION \
                  --instance-id $AWS_INSTANCE_ID \
                  --availability-zone $AWS_AVAILABILITY_ZONE \
                  --instance-os-user $AWS_INSTANCE_OS_USER \
                  --ssh-public-key file://aws_key.pub &&
                rsync --progress -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i aws_key" \
                  -arvz --delete ./static/public/ ec2-user@avalos.me:/var/www/blog.avalos.me/public_html/