forked from bluntelk/plane.watch
-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (106 loc) · 4.12 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
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