Skip to content

Commit

Permalink
fixing push for after merge to ecr
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjohnwright committed Oct 29, 2024
1 parent 970cfd6 commit 31e3b25
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: false
tags: reactome_chatbot:${{ github.sha }}
outputs: type=docker,dest=/tmp/image.tar

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: docker-image
name: image-artifact
path: /tmp/image.tar

docker-push:
Expand All @@ -68,29 +68,35 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v3
with:
name: docker-image
- uses: actions/download-artifact@v4
with:
name: image-artifact
path: /tmp

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.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: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
- id: get-hash
run: |
FULL_SHA=${{ github.sha }}
echo "SHORT_SHA=${FULL_SHA:0:7}" >> $GITHUB_OUTPUT
- env:
AWS_REGION: us-east-1
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_ROLE }}
aws-region: ${{ env.AWS_REGION }}

- id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public

- env:
AWS_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
AWS_REGISTRY_ALIAS: k2y5k6e2
AWS_REPO: reactome-chatbot
IMG_TAG: ${{ steps.get-hash.outputs.SHORT_SHA }}
run: |
docker load --input /tmp/image.tar
docker tag reactome_chatbot:${{ github.sha }} $ECR_REGISTRY/reactome-chatbot:$IMAGE_TAG
docker tag reactome_chatbot:${{ github.sha }} $ECR_REGISTRY/reactome-chatbot:latest
docker push $ECR_REGISTRY/reactome_chatbot:$IMAGE_TAG
docker push $ECR_REGISTRY/reactome_chatbot:latest
docker image tag tmp-tag $AWS_REGISTRY/$AWS_REGISTRY_ALIAS/$AWS_REPO:$IMG_TAG
docker image tag tmp-tag $AWS_REGISTRY/$AWS_REGISTRY_ALIAS/$AWS_REPO:latest
docker push $AWS_REGISTRY/$AWS_REGISTRY_ALIAS/$AWS_REPO:$IMG_TAG
docker push $AWS_REGISTRY/$AWS_REGISTRY_ALIAS/$AWS_REPO:latest

0 comments on commit 31e3b25

Please sign in to comment.