feat(content-utils): add commit history tracking to git info #769
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: Surface PR Changesets | |
| on: pull_request_target | |
| permissions: | |
| pull-requests: write | |
| checks: write | |
| statuses: write | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed files in the .changeset folder | |
| run: | | |
| { | |
| echo "all_changed_files<<EOF" | |
| git diff --name-only origin/main -- .changeset | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Check if any changesets contain minor or major changes | |
| id: check | |
| run: | | |
| echo "Checking for changesets marked as minor or major" | |
| echo "found=false" >> $GITHUB_OUTPUT | |
| regex="[\"']astro[\"']: (minor|major)" | |
| for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | |
| if [[ $(cat $file) =~ $regex ]]; then | |
| version="${BASH_REMATCH[1]}" | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "found=true" >> $GITHUB_OUTPUT | |
| echo "$file has a $version release tag" | |
| fi | |
| done | |
| - name: Add label | |
| uses: actions/github-script@v6 | |
| if: steps.check.outputs.found == 'true' | |
| env: | |
| issue_number: ${{ github.event.number }} | |
| with: | |
| script: | | |
| github.rest.issues.addLabels({ | |
| issue_number: process.env.issue_number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: ['semver: ${{ steps.check.outputs.version }}'] | |
| }); |