-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (71 loc) · 2.6 KB
/
version.yaml
File metadata and controls
80 lines (71 loc) · 2.6 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
name: version handler
on:
repository_dispatch:
types: [build]
permissions:
contents: write
pull-requests: write
jobs:
update-version:
name: Update workshop version
runs-on: ubuntu-24.04
steps:
- name: Turnstyle
uses: softprops/turnstyle@v3.2.3
- name: checkout
uses: actions/checkout@v6.0.2
with:
#ref: main
fetch-depth: 0
- name: set user profile
run: |
git config --global user.name 'jimboid'
git config --global user.email 'jimboid@users.noreply.github.com'
- name: change, log and push changes
id: update
run: |
if [ -z "$(git ls-remote --heads origin version-updates)" ]; then
echo "no branch version-updates, creating"
git checkout -b version-updates
else
echo "branch exists, checking it out"
git checkout version-updates
fi
jq --arg a "${{ github.event.client_payload.tag }}" '.containers."${{ github.event.client_payload.repo }}".latest = ($a)' workshop.json | jq "." | cat > workshop2.json; mv workshop2.json workshop.json
cat workshop.json
if [ -z "$(git status --porcelain)" ]; then
echo "no changes detected"
echo "changes=false" >> "$GITHUB_OUTPUT"
else
git add .
git commit -am "update ${{ github.event.client_payload.repo }} version to ${{ github.event.client_payload.tag }}"
if [ -z "$(git ls-remote --heads origin version-updates)" ]; then
echo "branch does not have upstream set, setting"
git push --set-upstream origin version-updates
else
echo "pushing changes"
git push
echo "changes=true" >> "$GITHUB_OUTPUT"
fi
fi
- name: check pr exists
id: checkpr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
prs=$(gh pr list \
--repo "$GITHUB_REPOSITORY" \
--head 'version-updates' \
--base 'main' \
--json title \
--jq 'length')
echo $prs
if ((prs > 0)); then
echo "exists=true" >> "$GITHUB_OUTPUT"
fi
- name: send PR
if: '!steps.checkpr.outputs.exists'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --base main --head version-updates --assignee jimboid --title "Update to workshop.json" --body "Update ${{ github.event.client_payload.repo }} version to ${{ github.event.client_payload.tag }}"