Skip to content

feat(ci): add docker and electron build and publish to release tag pipeline #7

feat(ci): add docker and electron build and publish to release tag pipeline

feat(ci): add docker and electron build and publish to release tag pipeline #7

name: Docker Build and Push
on:
pull_request:
branches: [main]
# 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
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Build webapp
run: |
cd webapp
npm ci
npm run build
- 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#refs/tags/}" >> $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 }}: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 }}:latest