-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Add workflow to push Docker image to Dockerhub and ECR (#37)
* Add workflow to push Docker image to Dockerhub and ECR * Update .github/workflows/docker.yml Co-authored-by: ee7 <[email protected]> * Update .github/workflows/docker.yml Co-authored-by: ee7 <[email protected]> * Update .github/workflows/docker.yml Co-authored-by: ee7 <[email protected]> * Update .github/workflows/docker.yml Co-authored-by: ee7 <[email protected]> Co-authored-by: ee7 <[email protected]>
- Loading branch information
1 parent
aba25f9
commit 7f85413
Showing
2 changed files
with
54 additions
and
25 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Push Docker images to Docker Hub and ECR | ||
|
||
on: | ||
push: | ||
branches: [main, master] | ||
|
||
jobs: | ||
multiple-registries: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # 2.3.4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@154c24e1f33dbb5865a021c99f1318cfebf27b32 # 1.1.1 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a # 2.1.3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@f3364599c6aa293cdc2b8391b1b56d0c30e45c8a # 1.8.0 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Log in to ECR | ||
uses: docker/login-action@f3364599c6aa293cdc2b8391b1b56d0c30e45c8a # 1.8.0 | ||
with: | ||
registry: ${{ env.ECR_REGISTRY }} | ||
username: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }} | ||
password: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@0db984c1826869dcd0740ff26ff75ff543238fd9 # 2.2.1 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: | | ||
${{ github.event.repository.full_name }}:latest | ||
${{ github.event.repository.full_name }}:${{ github.sha }} | ||
${{ env.ECR_REGISTRY }}/${{ github.event.repository.name }}:production | ||
${{ env.ECR_REGISTRY }}/${{ github.event.repository.name }}:${{ github.sha }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache |
This file was deleted.
Oops, something went wrong.