-
-
Notifications
You must be signed in to change notification settings - Fork 7
120 lines (104 loc) · 3.63 KB
/
build.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: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
- name: Run Biome
run: biome ci .
build-test-deploy:
name: Build, Test and Deploy
environment: build
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: ActivityPub Docker meta
id: activitypub-docker-metadata
uses: docker/metadata-action@v5
with:
images: |
europe-west4-docker.pkg.dev/ghost-activitypub/main/activitypub
tags: |
type=edge,branch=main
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,priority=1100
- name: Migrations Docker meta
id: migrations-docker-metadata
uses: docker/metadata-action@v5
with:
images: |
europe-west4-docker.pkg.dev/ghost-activitypub/main/migrations
tags: |
type=edge,branch=main
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,priority=1100
- name: "Build Docker Image for ActivityPub"
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: ${{ steps.activitypub-docker-metadata.outputs.tags }}
- name: "Build Docker Image for Migrations"
uses: docker/build-push-action@v6
with:
context: migrate
load: true
tags: ${{ steps.migrations-docker-metadata.outputs.tags }}
- name: "Run Tests"
run: yarn test
- name: "Login to GAR"
if: github.ref == 'refs/heads/main'
uses: docker/#-action@v3
with:
registry: europe-west4-docker.pkg.dev
username: _json_key
password: ${{ secrets.SERVICE_ACCOUNT_KEY }}
- name: "Push ActivityPub Docker Image"
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.activitypub-docker-metadata.outputs.tags }}
- name: "Push Migrations Docker Image"
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: migrate
push: true
tags: ${{ steps.migrations-docker-metadata.outputs.tags }}
- name: "Auth with Google Cloud"
if: github.ref == 'refs/heads/main'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }}
- name: "Deploy Migrations to Cloud Run"
if: github.ref == 'refs/heads/main'
uses: 'google-github-actions/deploy-cloudrun@v2'
with:
image: europe-west4-docker.pkg.dev/ghost-activitypub/main/migrations:${{ steps.migrations-docker-metadata.outputs.version }}
region: europe-west4
job: migrations
flags: '--wait --execute-now --set-cloudsql-instances=ghost-activitypub:europe-west4:activitypub-db'
- name: "Deploy ActivityPub to Cloud Run"
if: github.ref == 'refs/heads/main'
uses: 'google-github-actions/deploy-cloudrun@v2'
with:
image: europe-west4-docker.pkg.dev/ghost-activitypub/main/activitypub:${{ steps.activitypub-docker-metadata.outputs.version }}
region: europe-west4
service: activitypub