Repository navigation
104 lines (90 loc) · 4.57 KB
/
Copy pathsync-install-script.yml
File metadata and controls
104 lines (90 loc) · 4.57 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
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
name: Sync installers to landing
# The landing site vendors the installers byte-for-byte instead of proxying
# them (D-0007): @astrojs/vercel writes the Build Output config itself, so a
# `vercel.json` rewrite to raw.githubusercontent.com is silently ignored --
# and even working it would put githubusercontent in the install path and
# serve whatever is on the branch right now, with no deploy gate and no
# rollback. So the copy is pushed, and the sync originates here because this
# is where the canonical file lives: whenever an installer changes on `main`,
# mirror it into the site's scripts/ via a PR -- never a direct push, since
# that deploy gate is the point.
on:
push:
branches: [main]
paths:
- install.sh
- install.ps1
workflow_dispatch:
permissions:
contents: read
concurrency:
group: sync-install-script-${{ github.ref }}
cancel-in-progress: false
jobs:
sync:
name: Sync installers -> dirahq-landing
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout dirahq-cli
uses: actions/checkout@v7
with:
path: dirahq-cli
# App credentials as repo secrets: this repo is public, so the org-level
# copies do not reach it. `client-id` is the current input name; `app-id`
# is deprecated upstream and the org standardised on one name. Scoping
# by `owner` alone (no `repositories` list) grants the token access to
# every repo the App installation covers, which is what lets this
# workflow open a PR against the landing repo.
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.GH_APP_CLIENT_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout dirahq-landing
uses: actions/checkout@v7
with:
repository: dodi-smart/dirahq-landing
token: ${{ steps.app-token.outputs.token }}
path: dirahq-landing
- name: Vendor installers and open a sync PR
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
set -euo pipefail
sha_short=$(git -C dirahq-cli rev-parse --short HEAD)
branch="sync-install-script/${sha_short}"
mkdir -p dirahq-landing/scripts
# Plain `cp`, byte-identical -- D-0007. The landing copy carries no added
# header: the "vendored, do not edit here" notice lives in
# dirahq-landing/scripts/README.md instead, specifically so the drift check
# (a scheduled job on the landing side) is a plain `diff` with nothing to
# normalize. A previous version of this step prepended a two-line header,
# which broke that byte-for-byte guarantee -- do not reintroduce one.
cp dirahq-cli/install.sh dirahq-landing/scripts/install.sh
cp dirahq-cli/install.ps1 dirahq-landing/scripts/install.ps1
cd dirahq-landing
# git diff ignores untracked files, which would silently skip the very
# first sync (before scripts/install.{sh,ps1} exist at all) -- use status
# instead so both "new file" and "changed file" are caught.
if [ -z "$(git status --porcelain -- scripts/install.sh scripts/install.ps1)" ]; then
echo "install.sh and install.ps1 are already in sync with dirahq-landing -- nothing to do."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "${branch}"
git add scripts/install.sh scripts/install.ps1
git commit -s -m "chore(install): sync installers from dirahq-cli@${sha_short}"
git push -u origin "${branch}" --force
# Into develop, the landing trunk (and the branch checked out above):
# its target guard refuses PRs into main from anything but develop.
gh pr create \
--repo dodi-smart/dirahq-landing \
--base develop \
--head "${branch}" \
--title "chore(install): sync installers from dirahq-cli@${sha_short}" \
--body "Automated sync of \`scripts/install.sh\` and \`scripts/install.ps1\` from dodi-smart/dirahq-cli@${sha_short} (https://github.com/dodi-smart/dirahq-cli/commit/${sha_short}). Source of truth is \`install.sh\` / \`install.ps1\` at the CLI repo root -- do not edit the landing copies by hand." \
|| echo "a PR for ${branch} may already be open -- see dodi-smart/dirahq-landing pulls."