-
Notifications
You must be signed in to change notification settings - Fork 384
127 lines (120 loc) · 4.96 KB
/
pack.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
121
122
123
124
125
126
127
name: Build and publish
on:
push:
branches:
- master
- private-staging
tags:
- '*'
env:
PRODUCTION_TRACK: ${{ (github.ref_type == 'tag' && ((endsWith(github.ref_name, '-private-staging') && 'private-staging') || (!contains(github.ref_name, '-') && 'production'))) || (github.ref_type == 'branch' && github.ref_name == 'master' && 'staging') || '' }}
jobs:
push_to_registry:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
pppy/osu-web
# generate Docker tags based on the following events/attributes
# on tag event: tag using git tag, and as latest if the tag doesn't contain hyphens (pre-releases)
# on push event: tag using git sha, branch name and as latest-dev
tags: |
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && !contains(github.ref_name, '-') }}
type=raw,value=latest-dev,enable=${{ github.ref_type == 'branch' && github.ref_name == 'master' }}
type=raw,value=${{ github.ref_name }}
type=raw,value=${{ github.sha }},enable=${{ github.ref_type == 'branch' }}
flavor: |
latest=false
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
build-args: |
"APP_URL=https://osu.ppy.sh"
"DOCS_URL=https://osu.ppy.sh/docs/"
"GIT_SHA=osu-web@${{ (github.ref_type == 'tag' && github.ref_name) || github.sha }}"
context: .
file: ./Dockerfile.deployment
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
notify_pending_deploy:
if: ${{ github.ref_type == 'tag' && (!contains(github.ref_name, '-') || endsWith(github.ref_name, '-private-staging')) }}
runs-on: ubuntu-latest
needs:
- push_to_registry
steps:
-
name: Submit pending deployment notification
run: |
export TITLE="Pending osu-web $PRODUCTION_TRACK Deployment: $GITHUB_REF_NAME"
export URL="https://github.com/ppy/osu-web/actions/runs/$GITHUB_RUN_ID"
export DESCRIPTION="Docker image was built for tag $GITHUB_REF_NAME and awaiting approval for $PRODUCTION_TRACK deployment:
[View Workflow Run]($URL)"
export ACTOR_ICON="https://avatars.githubusercontent.com/u/$GITHUB_ACTOR_ID"
BODY="$(jq --null-input '{
"embeds": [
{
"title": env.TITLE,
"color": 15098112,
"description": env.DESCRIPTION,
"url": env.URL,
"author": {
"name": env.GITHUB_ACTOR,
"icon_url": env.ACTOR_ICON
}
}
]
}')"
curl \
-H "Content-Type: application/json" \
-d "$BODY" \
"${{ secrets.DISCORD_INFRA_WEBHOOK_URL }}"
trigger_deploy:
if: ${{ (github.ref_type == 'tag' && (!contains(github.ref_name, '-') || endsWith(github.ref_name, '-private-staging'))) || (github.ref_type == 'branch' && github.ref_name == 'master') }}
runs-on: ubuntu-latest
needs:
- push_to_registry
environment: ${{ (github.ref_type == 'tag' && ((endsWith(github.ref_name, '-private-staging') && 'private-staging') || (!contains(github.ref_name, '-') && 'production'))) || 'staging' }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.KUBERNETES_CONFIG_REPO_ACCESS_TOKEN }}
repository: ppy/osu-kubernetes-config
event-type: ${{ env.PRODUCTION_TRACK == 'staging' && 'dev-ppy-sh-deploy' || 'osu-web-deploy' }}
client-payload: |-
${{ env.PRODUCTION_TRACK == 'staging' && format('{{ "values": {{ "image": {{ "tag": "{0}" }} }} }}', github.sha) || format('{{ "dockerTag": "{0}", "productionTrack": "{1}" }}', github.ref_name, env.PRODUCTION_TRACK) }}
-
name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ppy
SENTRY_PROJECT: osu-web
SENTRY_URL: https://sentry.ppy.sh/
with:
environment: ${{ env.PRODUCTION_TRACK }}
version: osu-web@${{ github.ref_type == 'branch' && github.sha || github.ref_type == 'tag' && github.ref_name }}