diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000000..3ee18682df --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,19 @@ +## Releasing Image to ECR + +### Prerequisites + +- `act` - version >=0.2.71 + - https://nektosact.com/installation/index.html +- Logged in and authenticated to AWS + +### Copy Job +At the root of the repo, run: + +```shell +act -j 'release_to_ecr' --env=IMAGE_TAG=v0.1.2 --env=AWS_URL=aws.com --env-file <(aws configure export-credentials --format env) +``` +Make sure to set: +- `IMAGE_TAG` + - The tag of what image you want to copy from Dockerhub to ECR +- `AWS_URL` + - The URL to our AWS instance \ No newline at end of file diff --git a/.github/workflows/ecr-push.yaml b/.github/workflows/ecr-push.yaml new file mode 100644 index 0000000000..606e6d54e6 --- /dev/null +++ b/.github/workflows/ecr-push.yaml @@ -0,0 +1,29 @@ +name: HMDA ECR Image Push + + +jobs: + release_to_ecr: + name: Copy Docker image from Dockerhub to ECR + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Copy Image to ECR + run: | + docker pull hmda/hmda-platform:${{ env.IMAGE_TAG }} + docker tag hmda/hmda-platform:${{ env.IMAGE_TAG }} ${{ env.AWS_URL }}/hmda/hmda-platform:${{ env.IMAGE_TAG }} + docker push ${{ env.AWS_URL }}/hmda/hmda-platform:${{ env.IMAGE_TAG }} + + - name: Cleanup images + run: | + docker rmi hmda/hmda-platform:${{ env.IMAGE_TAG }} + docker rmi ${{ env.AWS_URL }}/hmda/hmda-platform:${{ env.IMAGE_TAG }}