Skip to content

Build

Build #85

Workflow file for this run

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 }}
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
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: npm ci
- name: Compile Typescript files
run: npm 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
run: echo ${{ steps.fetch_icons.outputs.files_changed }}
- name: Create code connect files
if: ${{ steps.fetch_icons.outputs.files_changed == 'true'}}
uses: ./.github/create_code_connect
- name: Create PR title
if: ${{ steps.fetch_icons.outputs.files_changed == 'true'}}
id: title
run: |
if [ ${{github.ref_name=='main'}} ]; then
TITLE='chore: Icon updates ${{ steps.date.outputs.date }}'
else
TITLE='chore: Icon updates ${{ steps.date.outputs.date }}(${{github.ref_name}})'
fi
echo "TITLE=$TITLE" >> $GITHUB_OUTPUT
- name: Push
if: ${{ steps.fetch_icons.outputs.files_changed == 'true'}}
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.title.outputs.TITLE}}"
git push --set-upstream origin ${{steps.branch_name.outputs.BRANCH_NAME}} -f
- name: Check if PR exists
if: ${{ steps.fetch_icons.outputs.files_changed == 'true'}}
run: echo "pr_exists=$(gh pr list -H ${{steps.branch_name.outputs.BRANCH_NAME}} --json number -q length)" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Create Pull Request
if: ${{env.pr_exists == 0 && steps.fetch_icons.outputs.files_changed == 'true'}}
run: gh pr create -B main -H ${{steps.branch_name.outputs.BRANCH_NAME}} --title "${{steps.title.outputs.TITLE}}" --body 'Created by the Zeta Icons bot'
env:
GITHUB_TOKEN: ${{ github.token }}