Build #324
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: Build | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # Runs automatically twice a week on Monday and Wednesday | |
| - cron: "0 8 * * 1" | |
| - cron: "0 8 * * 3" | |
| env: | |
| UPDATE_BRANCH_NAME: icon-updates | |
| jobs: | |
| fetch_icons: | |
| runs-on: ubuntu-latest | |
| name: Fetch icons and build output files | |
| # Uncomment below line if testing action via push to prevent recursion | |
| if: ${{ github.event.commits[0].author.name != 'Automated Version Bump' }} | |
| outputs: | |
| update: ${{ steps.fetch_icons.outputs.files_changed }} | |
| version: ${{ steps.package-version-new.outputs.current-version }} | |
| comment: ${{ steps.fetch_icons.outputs.comment }} | |
| steps: | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{github.ref_name}} | |
| - name: Create new branch name | |
| id: "branch_name" | |
| run: echo "BRANCH_NAME='${{env.UPDATE_BRANCH_NAME}}-${{github.ref_name}}'" >> $GITHUB_OUTPUT | |
| - name: Install packages | |
| run: yarn install --immutable | |
| - name: Compile Typescript files | |
| run: yarn run build:fetch-icons | |
| - name: Reset values if action is not scheduled. | |
| if: ${{github.event_name != 'schedule'}} | |
| run: | | |
| : > ./.github/fetch_icons/hash.txt | |
| - name: Get date / time | |
| id: date | |
| run: echo date=$(date +'%d %b %Y, %H:%M:%S') >> $GITHUB_OUTPUT | |
| - name: Fetch icons | |
| id: "fetch_icons" | |
| uses: ./.github/fetch_icons | |
| with: | |
| figma-access-token: ${{ secrets.FIGMA_PERSONAL_ACCESS_TOKEN }} | |
| date: ${{ steps.date.outputs.date }} | |
| actions-runner-debug: ${{secrets.ACTIONS_RUNNER_DEBUG}} | |
| - name: Icons changed | |
| continue-on-error: true | |
| run: echo ${{ steps.fetch_icons.outputs.files_changed }} | |
| - name: Create code connect files | |
| if: ${{ github.event_name == 'workflow_dispatch' || steps.fetch_icons.outputs.files_changed != ''}} | |
| uses: ./.github/create_code_connect | |
| - name: Check if PR exists | |
| if: ${{ github.event_name == 'workflow_dispatch' || steps.fetch_icons.outputs.files_changed != ''}} | |
| run: | | |
| pr=$(gh pr list -H ${{steps.branch_name.outputs.BRANCH_NAME}} --json number -q length) | |
| echo "pr_exists=$pr" >> $GITHUB_ENV | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Create PR details | |
| if: ${{ github.event_name == 'workflow_dispatch' || steps.fetch_icons.outputs.files_changed != ''}} | |
| id: pr | |
| run: | | |
| if [ ${{github.ref_name=='main'}} ]; then | |
| TITLE='iconchore: Icon updates ${{ steps.date.outputs.date }}' | |
| else | |
| TITLE='iconchore: Icon updates ${{ steps.date.outputs.date }}(${{github.ref_name}})' | |
| fi | |
| echo "TITLE=$TITLE" >> $GITHUB_OUTPUT | |
| echo "BODY<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "${{ steps.fetch_icons.outputs.comment }}">>"$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| echo "PR_BODY<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "<sub>Created by the Zeta Icons bot 🤖</sub><br />${{ steps.fetch_icons.outputs.comment }}">>"$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| - name: Push | |
| if: ${{ github.event_name == 'workflow_dispatch' || steps.fetch_icons.outputs.files_changed != ''}} | |
| run: | | |
| git checkout -b ${{steps.branch_name.outputs.BRANCH_NAME}} | |
| git config --global user.name "zeta-icons-bot" | |
| git config --global user.email "zeta-icons-bot@github.com" | |
| git add -A | |
| git commit -m "${{steps.pr.outputs.TITLE}}" -m "${{steps.pr.outputs.BODY}}" | |
| git push --set-upstream origin ${{steps.branch_name.outputs.BRANCH_NAME}} -f | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Create Pull Request | |
| if: ${{env.pr_exists == 0 && (github.event_name == 'workflow_dispatch' || steps.fetch_icons.outputs.files_changed != '')}} | |
| run: gh pr create -B main -H ${{steps.branch_name.outputs.BRANCH_NAME}} --title "${{steps.pr.outputs.TITLE}}" --body "${{steps.pr.outputs.PR_BODY}}" | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Update PR comment | |
| if: ${{env.pr_exists != 0 && (github.event_name == 'workflow_dispatch' || steps.fetch_icons.outputs.files_changed != '')}} | |
| run: gh pr edit ${{steps.branch_name.outputs.BRANCH_NAME}} -t "${{steps.pr.outputs.TITLE}}" -b "${{steps.pr.outputs.PR_BODY}}" | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} |