-
-
Notifications
You must be signed in to change notification settings - Fork 4
53 lines (44 loc) · 1.78 KB
/
Copy pathupdate-changesets.yml
File metadata and controls
53 lines (44 loc) · 1.78 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
name: update-changesets
env:
WORKFLOW_FILE: update-changesets.yml
on:
issue_comment:
types:
- created
jobs:
build:
if: startsWith(github.event.comment.body, '/update-changesets') && github.event.issue.locked
name: 🛠️ Update changesets
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
steps:
- name: 🚚 Checkout (gh_pages)
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: gh_pages
- name: 🔍 Check other workflows
run: |
# Get in-progress or queued workflows.
gh auth login --with-token < <(echo ${{ github.token }})
RESULT=`gh run list --workflow ${{ env.WORKFLOW_FILE }} --json status --jq '[.[] | select(.status == "in_progress")] | length == 1'`
# [ERROR] Other workflows are in progress.
[ "$RESULT" = "false" ] && echo "::error::Other '${{ env.WORKFLOW_FILE }}' workflows are in progress." && exit 1 || :
- name: 🛠️ Update changesets file
run: |
npx unity-changeset@latest list --all --all-lifecycles --pretty-json --with-external-source --xlts > dbV3
jq -r '.[] | "\(.version)\t\(.changeset)"' dbV3 > db
- name: Commit & Push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add dbV3 db
if git diff --cached --quiet; then
echo "no changes to commit"
exit 0
fi
git commit --amend -m "update-changesets: $(date '+%Y-%m-%d %H:%M:%S')"
git remote set-url origin "https://${GITHUB_ACTOR}:${{ github.token }}@github.com/${{ github.repository }}.git"
git push --force origin HEAD:gh_pages