Merge pull request #30 from cmbuckley/jekyll-upgrade #157
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: On Push | |
| on: | |
| push: | |
| branches: main | |
| pull_request: | |
| branches: main | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| commit_author: | |
| name: Get Commit Author | |
| runs-on: ubuntu-latest | |
| outputs: | |
| name: ${{ steps.author.outputs.name }} | |
| email: ${{ steps.author.outputs.email }} | |
| name_addr: ${{ format('{0} <{1}>', steps.author.outputs.name, steps.author.outputs.email) }} | |
| steps: | |
| - name: Get author | |
| id: author | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| name='buxbot[bot]' | |
| id=$(gh api "/users/$name" -q .id) | |
| echo "name=$name" >> $GITHUB_OUTPUT | |
| echo "email=$id+$name@users.noreply.github.com" >> $GITHUB_OUTPUT | |
| build_assets: | |
| uses: cmbuckley/.github/.github/workflows/pages.yml@main | |
| secrets: inherit | |
| with: | |
| deploy_enabled: ${{ github.event_name == 'push' }} | |
| custom_commands: | | |
| sudo apt-get update | |
| sudo apt-get install -y texlive-latex-base texlive-latex-recommended texlive-latex-extra aspell aspell-en | |
| make | |
| make spell | |
| check_role: | |
| name: Check Role | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed: ${{ steps.check.outputs.changed }} | |
| role: ${{ steps.details.outputs.role }} | |
| company: ${{ steps.details.outputs.company }} | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| - name: Get current role and location | |
| id: details | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| echo "existing=$(gh api users/${{ github.repository_owner }} -q .bio)" >> $GITHUB_OUTPUT | |
| echo "role=$(awk -v col=role -f _src/role.awk _src/cv.tex)" >> $GITHUB_OUTPUT | |
| echo "company=$(awk -v col=company -f _src/role.awk _src/cv.tex)" >> $GITHUB_OUTPUT | |
| - name: Compare roles | |
| id: check | |
| run: | | |
| echo "Current: ${{ steps.details.outputs.existing }}" | |
| if [ -n "${{ steps.details.outputs.role }}" ]; then | |
| echo "New: ${{ format('{0} at {1}', steps.details.outputs.role, steps.details.outputs.company) }}" | |
| echo "changed=${{ toJSON(steps.details.outputs.existing != format('{0} at {1}', steps.details.outputs.role, steps.details.outputs.company)) }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "No current role, not updating bio" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| update_role: | |
| name: Update Role | |
| runs-on: ubuntu-latest | |
| needs: [commit_author, check_role] | |
| if: ${{ github.event_name == 'push' && fromJSON(needs.check_role.outputs.changed) }} | |
| steps: | |
| - name: Generate a token | |
| id: token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| app-id: ${{ vars.BUXBOT_APP_ID }} | |
| private-key: ${{ secrets.BUXBOT_PRIVATE_KEY }} | |
| repositories: ${{ github.repository_owner }}.github.io | |
| - name: Update GitHub bio | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| run: gh api -X PATCH user -F "bio=${{ format('{0} at {1}', needs.check_role.outputs.role, needs.check_role.outputs.company) }}" | |
| - name: Checkout main site repo | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ github.repository_owner }}/${{ github.repository_owner }}.github.io | |
| token: ${{ steps.token.outputs.token }} | |
| path: ${{ github.workspace }}/site | |
| - name: Update role | |
| uses: jacobtomlinson/gha-find-replace@v3 | |
| with: | |
| find: 'role:.*' | |
| replace: 'role: ${{ needs.check_role.outputs.role }}' | |
| include: site/_config.yml | |
| - name: Update company | |
| uses: jacobtomlinson/gha-find-replace@v3 | |
| with: | |
| find: 'company:.*' | |
| replace: 'company: ${{ needs.check_role.outputs.company }}' | |
| include: site/_config.yml | |
| - name: Create Pull Request | |
| id: pull-request | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ steps.token.outputs.token }} | |
| path: ${{ github.workspace }}/site | |
| branch: role-${{ github.run_id }} | |
| author: ${{ needs.commit_author.outputs.name_addr }} | |
| committer: ${{ needs.commit_author.outputs.name_addr }} | |
| commit-message: Update role from CV | |
| title: Update role from CV | |
| body: 'Updates role to match CV repository. See full diff: ${{ github.event.compare }}' | |
| - name: Check Pull Request | |
| if: steps.pull-request.outputs.pull-request-operation == '' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: core.setFailed('No Pull Request was created') |