resource_types:
- name: fossil-resource
type: docker-image
source:
repository: avalos/fossil-concourse-resource
tag: latest
resources:
- name: fossil
type: fossil-resource
source:
url: https://fossil.avalos.me/avalos-indie-blog
branch: 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: alpine, tag: edge}
inputs:
- name: fossil
path: .
outputs:
- name: blog
path: public
run:
path: /bin/sh
args:
- -c
- apk update && apk add hugo && hugo
- task: deploy
config:
platform: linux
image_resource:
type: docker-image
source: {repository: alpine, tag: edge}
inputs:
- name: blog
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 ./blog/ ec2-user@avalos.me:/var/www/blog.avalos.me/public_html/