build #196
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: checkout | |
| uses: actions/checkout@v6.0.0 | |
| with: | |
| 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: update json | |
| run: | | |
| 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 | |
| - name: log the change | |
| run: | | |
| cat workshop.json | |
| - name: push changes | |
| run: | | |
| if [ -z "$(git status --porcelain)" ]; then | |
| echo "no changes detected" | |
| else | |
| if [ -z "$(git branch --list version-updates)" ]; then | |
| git checkout -b version-updates | |
| else | |
| git checkout version-updates | |
| fi | |
| git commit -am "update ${{ github.event.client_payload.repo }} version to ${{ github.event.client_payload.tag }}" | |
| if [ -z "$(git branch --list version-updates)" ]; git push --set-upstream origin version-updates | |
| git push | |
| 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' | |
| uses: peter-evans/create-pull-request@v7.0.9 | |
| with: | |
| commit-message: Update ${{ github.event.client_payload.repo }} version to ${{ github.event.client_payload.tag }} | |
| branch: version-updates | |
| title: "Update to workshop.json" | |
| body: | | |
| Update ${{ github.event.client_payload.repo }} version to ${{ github.event.client_payload.tag }} | |
| base: main | |
| assignees: jimboid | |
| signoff: false | |
| draft: false |