Skip to content

πŸš€ HCA Atlas Tracker Dev Deploy πŸš€ #217

πŸš€ HCA Atlas Tracker Dev Deploy πŸš€

πŸš€ HCA Atlas Tracker Dev Deploy πŸš€ #217

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 }}."