-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (70 loc) · 2.56 KB
/
release.yaml
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
name: Release
on:
push:
branches: [main]
jobs:
get-next-version:
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci && npx semantic-release --dry-run
id: get-next-version
env:
GITHUB_TOKEN: ${{ secrets.HOMEPAGE_RELEASE_TOKEN }}
outputs:
is-new-release: ${{ steps.get-next-version.outputs.new-release-published }}
version: ${{ steps.get-next-version.outputs.new-release-version }}
release:
runs-on: ubuntu-latest
needs: get-next-version
if: needs.get-next-version.outputs.is-new-release == 'true'
permissions:
contents: "read"
id-token: "write"
env:
IMAGE: europe-west2-docker.pkg.dev/${{ secrets.PROJECT_ID }}/pauljs-io/homepage
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Authenticate with Google Cloud
uses: "google-github-actions/auth@v0.8.3"
with:
workload_identity_provider: ${{ secrets.WI_PROVIDER }}
service_account: ${{ secrets.GSA_REGISTRY }}
- name: Authenticate Docker
run: gcloud auth configure-docker europe-west2-docker.pkg.dev --quiet
- name: Setup Docker BuildKit
uses: docker/setup-buildx-action@v2
- name: Build & Publish Image
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE }}:${{ needs.get-next-version.outputs.version }}
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
- name: Update staging environment
run: |
curl -XPOST \
-H "Accept:application/vnd.github+json" \
-H "Authorization: token ${{ secrets.APPS_RELEASE }}" \
-H "Content-Type:application/json" \
https://api.github.com/repos/paulsilcock/app-of-apps/actions/workflows/deploy.yaml/dispatches \
--data '{"ref": "main", "inputs": {"app": "homepage", "tag": "${{ needs.get-next-version.outputs.version }}", "env": "staging"} }'
- name: Create GitHub Release
run: npm ci && npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.HOMEPAGE_RELEASE_TOKEN }}