Docker Build and Push #13
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: Docker Build and Push | |
on: | |
workflow_run: | |
workflows: ["Release Build"] | |
types: [completed] | |
env: | |
REGISTRY_IMAGE_API: fynnfluegge/rocketnotes-api | |
REGISTRY_IMAGE_WEBAPP: fynnfluegge/rocketnotes-webapp | |
AWS_REGION: ${{ vars.AWS_REGION }} | |
DOMAIN_NAME: ${{ vars.DOMAIN_NAME }} | |
API_URL: ${{ vars.API_URL }} | |
COGNITO_USER_POOL_ID: ${{ vars.COGNITO_USER_POOL_ID }} | |
COGNITO_APP_CLIENT_ID: ${{ vars.COGNITO_APP_CLIENT_ID }} | |
REDIRECT_SIGN_IN: ${{ vars.REDIRECT_SIGN_IN }} | |
REDIRECT_SIGN_OUT: ${{ vars.REDIRECT_SIGN_OUT }} | |
AUTH_GUARD_REDIRECT: ${{ vars.AUTH_GUARD_REDIRECT }} | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: dawidd6/action-download-artifact@v2 | |
with: | |
name: webapp-build | |
path: webapp/build | |
run_id: ${{ github.event.workflow_run.id }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- uses: aws-actions/setup-sam@v2 | |
with: | |
use-installer: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: sam build | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract release tag | |
id: get_tag | |
run: echo "RELEASE_TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV | |
- name: Build and push Docker image api | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile.sam | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.REGISTRY_IMAGE_API }}:${{ env.RELEASE_TAG }} | |
${{ env.REGISTRY_IMAGE_API }}:latest | |
- name: Build and push Docker image webapp | |
uses: docker/build-push-action@v5 | |
with: | |
context: webapp/. | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.REGISTRY_IMAGE_WEBAPP }}:${{ env.RELEASE_TAG }} | |
${{ env.REGISTRY_IMAGE_WEBAPP }}:latest |