-
Notifications
You must be signed in to change notification settings - Fork 59
110 lines (94 loc) · 3.23 KB
/
Copy pathrelease-images.yml
File metadata and controls
110 lines (94 loc) · 3.23 KB
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
name: release-images
on:
workflow_run:
workflows: ["tag-repo-version"]
types: [completed]
jobs:
build-and-push:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
tag: ${{ steps.tag.outputs.tag }}
env:
SOURCE_SHA: ${{ github.event.workflow_run.head_sha }}
strategy:
matrix:
service: [web, worker]
steps:
- name: Checkout (full history for tags)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch tags
run: git fetch --tags --force
- name: Resolve the tag that points at the workflow SHA
id: tag
shell: bash
run: |
set -euo pipefail
TAG="$(git tag --points-at "${SOURCE_SHA}" \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| head -n1 || true)"
if [ -z "${TAG}" ]; then
exit 1
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
- name: Checkout the exact tag
run: git checkout ${{ steps.tag.outputs.tag }}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
# Login to GHCR
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & push ${{ matrix.service }}
uses: docker/build-push-action@v6
with:
context: .
file: apps/${{ matrix.service }}/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository_owner }}/kurrier-${{ matrix.service }}:${{ steps.tag.outputs.tag }}
ghcr.io/${{ github.repository_owner }}/kurrier-${{ matrix.service }}:latest
docker.io/${{ secrets.DOCKERHUB_USERNAME }}/kurrier-${{ matrix.service }}:${{ steps.tag.outputs.tag }}
docker.io/${{ secrets.DOCKERHUB_USERNAME }}/kurrier-${{ matrix.service }}:latest
build-args: |
NODE_ENV=production
JWT_SECRET=build_dummy_jwt_secret
APP_SECRET_ENCRYPTION_KEY=build_dummy_app_secret_encryption_key
S3_REGION=garage
S3_BUCKET=build-bucket
S3_ENDPOINT=http://localhost:3900
S3_ACCESS_KEY=build_access_key
S3_SECRET_KEY=build_secret_key
S3_FORCE_PATH_STYLE=true
provenance: true
sbom: true
github-release:
needs: build-and-push
runs-on: ubuntu-latest
permissions:
contents: write
if: ${{ needs.build-and-push.outputs.tag != '' }}
steps:
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.build-and-push.outputs.tag }}
name: ${{ needs.build-and-push.outputs.tag }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}