|
1
|
name: Nudge Preview Bump |
|
2
|
|
|
3
|
# Nudges the medusajs/dtc-starter repo to bump its `@medusajs/*` dependencies to |
|
4
|
# the latest `preview` version and verify the resulting Medusa Cloud deployment. |
|
5
|
# All of that logic lives in dtc-starter's own `bump-preview.yml` workflow, which |
|
6
|
# is triggered by pushing a `bump-preview-*` tag and deletes the tag when it |
|
7
|
# finishes. This workflow's only job is to create such a tag pointing at |
|
8
|
# dtc-starter's current `preview` HEAD. |
|
9
|
# |
|
10
|
# Triggered on a daily schedule, manually via workflow_dispatch, and by the |
|
11
|
# release job in `trigger-release.yml` after a successful preview publish. |
|
12
|
|
|
13
|
on: |
|
14
|
workflow_dispatch: |
|
15
|
schedule: |
|
16
|
- cron: "0 6 * * *" # daily at 06:00 UTC |
|
17
|
|
|
18
|
concurrency: |
|
19
|
group: ${{ github.workflow }} |
|
20
|
cancel-in-progress: true |
|
21
|
|
|
22
|
permissions: |
|
23
|
contents: read # we only read this repo; the cross-repo write uses DTC_STARTER_TOKEN |
|
24
|
|
|
25
|
jobs: |
|
26
|
nudge: |
|
27
|
name: Tag dtc-starter to bump preview |
|
28
|
runs-on: ubuntu-latest |
|
29
|
steps: |
|
30
|
# The default GITHUB_TOKEN cannot write to another repository. Mint a |
|
31
|
# short-lived installation token from the Medusa OS Bot GitHub App instead, |
|
32
|
# scoped to medusajs/dtc-starter. The app must be installed on that repo |
|
33
|
# with `contents: write`. |
|
34
|
- name: Generate GitHub App token |
|
35
|
id: app-token |
|
36
|
uses: actions/create-github-app-token@v1 |
|
37
|
with: |
|
38
|
app-id: ${{ secrets.MEDUSA_APP_ID }} |
|
39
|
private-key: ${{ secrets.MEDUSA_APP_PRIVATE_KEY }} |
|
40
|
owner: medusajs |
|
41
|
repositories: dtc-starter |
|
42
|
|
|
43
|
- name: Create bump-preview tag on dtc-starter |
|
44
|
env: |
|
45
|
GH_TOKEN: ${{ steps.app-token.outputs.token }} |
|
46
|
TARGET_REPO: medusajs/dtc-starter |
|
47
|
run: | |
|
48
|
SHA=$(gh api "repos/$TARGET_REPO/git/ref/heads/preview" --jq '.object.sha') |
|
49
|
if [ -z "$SHA" ]; then |
|
50
|
echo "::error::Could not resolve the preview HEAD of $TARGET_REPO." |
|
51
|
exit 1 |
|
52
|
fi |
|
53
|
TAG="bump-preview-$(date -u +%Y%m%d%H%M%S)" |
|
54
|
gh api --method POST "repos/$TARGET_REPO/git/refs" \ |
|
55
|
-f ref="refs/tags/$TAG" \ |
|
56
|
-f sha="$SHA" |
|
57
|
echo "Created tag $TAG on $TARGET_REPO at $SHA" |
|
58
|
echo "dtc-starter's bump-preview workflow will run and delete the tag when finished." |