Skip to content

Commit c304eae

Browse files
authored
Merge pull request #783 from notch8/deploy-in-ci
🔧 Deploy and publish from the push's own CI run
2 parents 7c7e7cf + 14d019a commit c304eae

4 files changed

Lines changed: 32 additions & 55 deletions

File tree

‎.github/workflows/build-test-lint.yaml‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,28 @@ jobs:
4949
reports:
5050
if: always()
5151
needs: [test, lint]
52-
uses: notch8/actions/.github/workflows/report.yaml@v1.0.11
52+
uses: notch8/actions/.github/workflows/report.yaml@v1.0.11
53+
54+
# Deploying from this run (not a separate workflow_run-triggered Deploy) keeps the run on the
55+
# pushed commit: GitHub shows a workflow_run's SHA and branch as the default branch's.
56+
deploy:
57+
needs: [test, lint]
58+
if: ${{ github.event_name == 'push' }}
59+
concurrency:
60+
group: deploy-${{ github.ref_name == 'main' && 'dev' || github.ref_name }}
61+
cancel-in-progress: false
62+
uses: notch8/actions/.github/workflows/deploy.yaml@v1.0.12
63+
secrets: inherit
64+
with:
65+
environment: ${{ github.ref_name == 'main' && 'dev' || github.ref_name }}
66+
67+
publish-release:
68+
needs: deploy
69+
if: ${{ github.ref_name == 'production' }}
70+
permissions:
71+
actions: read
72+
contents: write
73+
uses: notch8/actions/.github/workflows/publish-release.yaml@v1.0.13
74+
with:
75+
sha: ${{ github.sha }}
76+
deploy-run-id: ${{ github.run_id }}

‎.github/workflows/deploy.yaml‎

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
name: "Deploy"
2-
run-name: Deploy (${{ github.event.workflow_run.head_branch || github.ref_name }} -> ${{ inputs.environment || (github.event.workflow_run.head_branch == 'main' && 'dev') || github.event.workflow_run.head_branch }}) by @${{ github.actor }}
2+
# Ad-hoc deploys and rollbacks. Pushes to main, staging and production deploy from their
3+
# Build Test Lint run instead.
4+
run-name: Deploy (${{ github.ref_name }} -> ${{ inputs.environment }}) by @${{ github.actor }}
35
on:
4-
workflow_run:
5-
workflows: ["Build Test Lint"]
6-
types: [completed]
7-
branches:
8-
- main
9-
- staging
10-
- production
116
workflow_dispatch:
127
inputs:
138
environment:
@@ -25,36 +20,13 @@ on:
2520
required: false
2621
default: false
2722

28-
jobs:
29-
determine-environment:
30-
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') }}
31-
runs-on: ubuntu-latest
32-
outputs:
33-
environment: ${{ steps.set.outputs.environment }}
34-
steps:
35-
- id: set
36-
name: Map branch/input to target environment
37-
env:
38-
EVENT_NAME: ${{ github.event_name }}
39-
INPUT_ENVIRONMENT: ${{ inputs.environment }}
40-
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
41-
run: |
42-
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
43-
echo "environment=$INPUT_ENVIRONMENT" >> "$GITHUB_OUTPUT"
44-
else
45-
case "$HEAD_BRANCH" in
46-
main) echo "environment=dev" >> "$GITHUB_OUTPUT" ;;
47-
staging) echo "environment=staging" >> "$GITHUB_OUTPUT" ;;
48-
production) echo "environment=production" >> "$GITHUB_OUTPUT" ;;
49-
esac
50-
fi
5123

24+
jobs:
5225
deploy:
53-
needs: determine-environment
5426
concurrency:
55-
group: deploy-${{ needs.determine-environment.outputs.environment }}
27+
group: deploy-${{ inputs.environment }}
5628
cancel-in-progress: false
5729
uses: notch8/actions/.github/workflows/deploy.yaml@v1.0.12
5830
secrets: inherit
5931
with:
60-
environment: ${{ needs.determine-environment.outputs.environment }}
32+
environment: ${{ inputs.environment }}

‎.github/workflows/publish-release.yml‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Promotion is GitLab Flow: merge-commit PRs `main` -> `staging` -> `production`.
239239
| `production` | production | `r2-besties` | `palni-palci-knapsack-production` |
240240

241241
- Production window: Thursdays 3-5pm Pacific. Never on a Friday.
242-
- Release tags continue the `v0.2.x` line. Pushes to `staging` and `production` draft `v<next>-rc` and `v<next>`; after a verified production deploy, approving the Publish Release run publishes the stable draft at the deployed commit. Each draft records the pinned Hyku version and SHA.
242+
- Release tags continue the `v0.2.x` line. Pushes to `staging` and `production` draft `v<next>-rc` and `v<next>`; after a verified production deploy, approving the `publish-release` job in the production Build Test Lint run publishes the stable draft at the deployed commit. Each draft records the pinned Hyku version and SHA.
243243
- Production deploys wait for approval from `@notch8/hyku-knapsack-owners` on the `production` environment.
244244
- Before merging a promotion PR, capture the tenant regression baseline.
245245
- Announcement channel: **#n8-palni-palci**, the client's channel, so write for the client

0 commit comments

Comments
 (0)