Merge pull request #212 from plane-watch/dependabot/docker/docker/pw_… #139
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: Deploy | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
# Don't trigger if it's just a documentation update | |
paths-ignore: | |
- '**.md' | |
- '**.MD' | |
- '**.yml' | |
- 'LICENSE' | |
- '.gitattributes' | |
- '.gitignore' | |
- '.dockerignore' | |
# Set workflow-wide environment variables | |
env: | |
GHCR_IMAGE: ${{ github.repository }} | |
GHCR_REGISTRY: ghcr.io | |
jobs: | |
deploy_ghcr_multiarch: | |
name: Deploy ghcr.io (Multi-Arch) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image: | |
- pw_discord_bot | |
- pw_atc_api | |
- pw_ingest | |
- pw_router | |
- pw_ws_broker | |
steps: | |
# Check out our code | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get short commit hash | |
id: vars | |
shell: bash | |
run: | | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
# Generate version | |
- name: Determine semantic-gitcommit version | |
uses: paulhatch/[email protected] | |
id: semantic-gitcommit | |
with: | |
# The prefix to use to identify tags | |
tag_prefix: "v" | |
# A string which, if present in a git commit, indicates that a change represents a | |
# major (breaking) change, supports regular expressions wrapped with '/' | |
major_pattern: "(MAJOR)" | |
# Same as above except indicating a minor change, supports regular expressions wrapped with '/' | |
minor_pattern: "(MINOR)" | |
# A string to determine the format of the version output | |
version_format: "${major}.${minor}.${patch}.${increment}-${{ steps.vars.outputs.sha_short }}" | |
# If this is set to true, *every* commit will be treated as a new version. | |
bump_each_commit: false | |
# If true, the body of commits will also be searched for major/minor patterns to determine the version type. | |
search_commit_body: false | |
# Log into ghcr (so we can push images) | |
- name: Login to ghcr.io | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.GHCR_REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Get metadata from repo | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }} | |
labels: | | |
org.opencontainers.image.version=${{ steps.semantic-gitcommit.outputs.version }} | |
# Set up QEMU for multi-arch builds | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
# Set up buildx for multi platform builds | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
# Build only (if not push to main branch) | |
- name: Build only - ${{ matrix.image }} | |
if: ${{ github.event_name != 'push' && github.ref != 'refs/heads/main' }} | |
uses: docker/build-push-action@v2 | |
with: | |
build-args: IMAGE_VERSION="${{ steps.semantic-gitcommit.outputs.version }}" | |
context: . | |
file: docker/${{ matrix.image }}/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: false | |
tags: ghcr.io/${{ env.GHCR_IMAGE }}:${{ matrix.image }},ghcr.io/${{ env.GHCR_IMAGE }}:${{ matrix.image }}_${{ steps.semantic-gitcommit.outputs.version }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# Build & Push (if push to main branch) | |
- name: Build & Push - ${{ matrix.image }} | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
uses: docker/build-push-action@v2 | |
with: | |
build-args: IMAGE_VERSION="${{ steps.semantic-gitcommit.outputs.version }}" | |
context: . | |
file: docker/${{ matrix.image }}/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ghcr.io/${{ env.GHCR_IMAGE }}:${{ matrix.image }},ghcr.io/${{ env.GHCR_IMAGE }}:${{ matrix.image }}_${{ steps.semantic-gitcommit.outputs.version }},ghcr.io/${{ env.GHCR_IMAGE }}:latest |