Build Docker Images #47
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: Build Docker Images | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
jobs: | |
push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- name: Build | |
run: npm ci | |
- name: Log into registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | |
- name: Build images | |
run: | | |
IMAGE_BASE=docker.pkg.github.com/${{ github.repository }}/ | |
# Change all uppercase to lowercase | |
export IMAGE_BASE=$(echo $IMAGE_BASE | tr '[A-Z]' '[a-z]') | |
# Get the version and build number from the script | |
export IMAGE_VERSION=$(npm run --silent version) | |
echo IMAGE_BASE=$IMAGE_BASE | |
echo IMAGE_VERSION=$IMAGE_VERSION | |
# now build the images | |
npm run docker:build | |
echo "Pushing ${IMAGE_BASE}frontend:${IMAGE_VERSION}" | |
docker push "${IMAGE_BASE}frontend:${IMAGE_VERSION}" | |
echo "Pushing ${IMAGE_BASE}backend:${IMAGE_VERSION}" | |
docker push "${IMAGE_BASE}backend:${IMAGE_VERSION}" | |
- name: Log out of registry | |
run: docker logout |