π HCA Atlas Tracker Dev Deploy π #219
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: HCA Atlas Tracker Dev Deploy | |
run-name: π HCA Atlas Tracker Dev Deploy π | |
on: | |
push: | |
branches: [main] | |
env: | |
AWS_REGION: ${{ secrets.DEV_AWS_REGION }} | |
IMAGE_TAG: ${{ github.sha }} | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
Build-and-Push-Docker-Image: | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "π The job was automatically triggered by a ${{ github.event_name }} event." | |
- run: echo "π§ This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
- run: echo "π The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | |
- run: echo "π This job's run number is${{ env.IMAGE_TAG }}" | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- run: echo "π‘ The ${{ github.repository }} repository has been cloned to the runner." | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ROLE_NAME }} | |
role-session-name: ${{ secrets.DEV_ROLE_SESSION_NAME }} | |
aws-region: ${{ secrets.DEV_AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build Docker container | |
id: build-image | |
run: | | |
docker build --build-arg ENVIRONMENT=dev -t hca-tracker-node:${{ env.IMAGE_TAG }} . -f Dockerfile.node | |
docker tag hca-tracker-node:${{ env.IMAGE_TAG }} ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.DEV_AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPO_NAME }}:${{ env.IMAGE_TAG }} | |
docker tag hca-tracker-node:${{ env.IMAGE_TAG }} ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.DEV_AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPO_NAME }}:latest | |
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.DEV_AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPO_NAME }}:${{ env.IMAGE_TAG }} | |
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.DEV_AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPO_NAME }}:latest | |
echo "image=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.DEV_AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPO_NAME }}:${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT | |
- name: List ECR Images | |
run: | | |
echo "List of images in ECR repository: $(aws ecr list-images --repository-name ${{ secrets.ECR_REPO_NAME }} | jq '.imageIds[]')" | |
- name: Invalidate CloudFront distribution | |
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" | |
- run: echo "π This job's status is ${{ job.status }}." |