add utc timestamp #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, push and deploy Docker image | |
on: | |
push: | |
branches: [prod] | |
env: | |
AWS_REGION: ap-southeast-1 # set this to your preferred AWS region | |
EBS_APPLICATION_NAME: firecloud # set this to your EBS application name | |
EBS_ENVIRONMENT_NAME: Firecloud-env-1 # set this to your EBS environment name | |
ECR_REPOSITORY: firecloud-application-versions-prod # set this to your ECR repository name | |
ECR_REPOSITORY_URI: 892404399729.dkr.ecr.ap-southeast-1.amazonaws.com | |
S3_BUCKET_NAME: firecloud-application-versions-prod | |
defaults: | |
run: | |
working-directory: ./fire-cloud | |
jobs: | |
build-push-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:firecloud_${{github.run_number}} . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:firecloud_${{github.run_number}} | |
- name: Replace image in docker compose file | |
env: | |
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} | |
ECR_REPOSITORY_URI: ${{ env.ECR_REPOSITORY_URI }} | |
run: | | |
cp docker-compose.prod.yml docker-compose.yml | |
sed -i "s/<ECR_REGISTRY>/$ECR_REPOSITORY_URI/g" docker-compose.yml | |
sed -i "s/<SERVER_NAME>/$ECR_REPOSITORY/g" docker-compose.yml | |
sed -i "s/<TAG>/firecloud_${{github.run_number}}/g" docker-compose.yml | |
- name: Zip the docker compose file | |
run: | | |
zip deploy.zip docker-compose.yml | |
- name: Upload zip to S3 | |
env: | |
S3_BUCKET_NAME: ${{ env.S3_BUCKET_NAME }} | |
run: | | |
aws s3 cp deploy.zip s3://$S3_BUCKET_NAME/firecloud_deploy_${{github.run_number}}.zip | |
rm deploy.zip | |
- name: Deploy to EBS | |
run: | | |
aws elasticbeanstalk create-application-version \ | |
--application-name ${{ env.EBS_APPLICATION_NAME }} --version-label ${{github.run_number}} \ | |
--source-bundle S3Bucket=${{ env.S3_BUCKET_NAME }},S3Key=firecloud_deploy_${{github.run_number}}.zip | |
aws elasticbeanstalk update-environment \ | |
--environment-name ${{ env.EBS_ENVIRONMENT_NAME }} --version-label ${{github.run_number}} |