Docker WebApp #141
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 WebApp | |
on: | |
workflow_run: | |
workflows: ["Angular WebApp Build"] | |
types: [completed] | |
branches: [develop, master] | |
tags: ['v*.*.*', 'latest'] | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch or commit to build' | |
required: true | |
default: 'develop' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }}-webapp | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'release' || github.event_name == 'workflow_dispatch' }} | |
steps: | |
- uses: haya14busa/action-cond@v1 | |
id: condval | |
with: | |
cond: ${{ github.event_name == 'workflow_dispatch' }} | |
if_true: "${{ github.event.inputs.branch }}" | |
if_false: " ${{ github.ref_name }}" | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.condval.outputs.value }} | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | |
with: | |
images: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
# GitHub Action to install QEMU static binaries. | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
# GitHub Action to set up Docker Buildx. | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
# Build and push Docker image with Buildx (don't push on PR) | |
# https://github.com/docker/build-push-action | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: WebApp/ | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} ${{ env.BRANCH}} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64 | |
cache-from: type=gha, scope=${{ github.workflow }} | |
cache-to: type=gha, scope=${{ github.workflow }} |