Repository navigation
69 lines (64 loc) · 2.84 KB
/
Copy pathdeploy-dev.yml
File metadata and controls
69 lines (64 loc) · 2.84 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
name: Deploy dev
# Reconciles the dev apis service, its datasets worker, and its jobs to dev's
# current tip, whatever triggered the run. The steps live in deploy.yml, which
# deploy-prod.yml shares; this file chooses the triggers and the `dev` GitHub
# Environment.
#
# The trigger is `workflow_run` on CI, not `push`, because a push trigger
# races CI's own run for the same commit: an older commit's CI can finish
# after a newer commit's. The job requires
# `github.event.workflow_run.conclusion == 'success'` and a CI run started by a
# push, so a failed or cancelled run deploys nothing, and neither does a fork
# pull request from a branch named dev. deploy.yml resolves dev's tip for
# itself, so a run triggered by an older commit still deploys the newest green
# commit.
#
# dev is the branch CONTRIBUTING.md maps to the dev environment.
#
# A further environment would be one more caller like this one, with its own
# triggers and GitHub Environment.
on:
workflow_run:
# The `name:` of ci.yml, which is the handle GitHub matches on.
workflows: [CI]
types: [completed]
# The branch the triggering run ran on. CI runs on pull requests too, but
# those runs report the PR's head branch, so only a run on dev matches.
branches: [dev]
workflow_dispatch: {}
permissions:
contents: read
concurrency:
# One group for the branch rather than per commit: every deploy mutates the
# same service and the same two migration jobs, so they must not overlap.
# cancel-in-progress stays false: a run stopped between pointing a migration
# job at a new image and executing it leaves the job and the service on
# different images. queue: max queues every pending run in this group
# (up to 100) and executes them in order, instead of GitHub's default of
# cancelling the previous pending run whenever a new one is queued. A
# dispatch queued behind a running deploy would otherwise be cancelled and
# never deploy. Each workflow_run in the queue resolves dev's tip for
# itself when it runs rather than trusting the commit that triggered it,
# so a queued workflow_run still reconciles the service to dev's actual
# tip at that time; a queued dispatch deploys exactly the commit it was
# dispatched from.
group: deploy-dev
cancel-in-progress: false
queue: max
jobs:
deploy:
# A CI run that failed or was cancelled deploys nothing. A fork PR from a
# branch named dev reports head_branch dev, so only a push run counts.
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push')
permissions:
contents: read
id-token: write
actions: read
uses: ./.github/workflows/deploy.yml
with:
environment: dev
# deploy.yml reads WIF_PROVIDER and WIF_SA from its own environment.
secrets: inherit