Skip to content

build

build #332

Workflow file for this run

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.2
- name: checkout
uses: actions/checkout@v6.0.1
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 }}"