Skip to content

Commit

Permalink
ci: conditionally run github-script on cronjobs
Browse files Browse the repository at this point in the history
The PR create step was always executed even if there were no new files, which caused an error
  • Loading branch information
DSil committed Feb 9, 2024
1 parent b85ffdd commit 7a0a240
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/cron-update-contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
- cron: "0 11 * * *"
workflow_dispatch:

env:
new_files: false

jobs:
cron-update-contributors:
runs-on: ubuntu-latest
Expand All @@ -29,17 +32,19 @@ jobs:
git add --all
if git diff-index --quiet HEAD; then
echo "No changes to contributors. Exiting."
exit 0
echo "new_files=false" >> $GITHUB_ENV
else
git checkout -b docs/update-contributors
git commit -m "docs: update contributors"
git push origin docs/update-contributors
echo "new_files=true" >> $GITHUB_ENV
fi
env:
FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }}

- name: Create PR
uses: actions/github-script@v6
if: env.new_files == 'true'
with:
script: |
github.rest.pulls.create({
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/cron-update-icons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
- cron: "0 10 * * *"
workflow_dispatch:

env:
new_files: false

jobs:
cron-update-icons:
runs-on: ubuntu-latest
Expand All @@ -29,17 +32,19 @@ jobs:
git add --all
if git diff-index --quiet HEAD; then
echo "No changes to icons. Exiting."
exit 0
echo "new_files=false" >> $GITHUB_ENV
else
git checkout -b feat/update-icons-and-svgs
git commit -m "feat(icons): update icons from figma"
git push origin feat/update-icons-and-svgs
echo "new_files=true" >> $GITHUB_ENV
fi
env:
FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }}

- name: Create PR
uses: actions/github-script@v6
if: env.new_files == 'true'
with:
script: |
github.rest.pulls.create({
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/cron-update-statuses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
- cron: "0 9 * * *"
workflow_dispatch:

env:
new_files: false

jobs:
cron-update-statuses:
runs-on: ubuntu-latest
Expand All @@ -29,15 +32,17 @@ jobs:
git add --all
if git diff-index --quiet HEAD; then
echo "No changes to component statuses. Exiting."
exit 0
echo "new_files=false" >> $GITHUB_ENV
else
git checkout -b docs/update-component-statuses
git commit -m "chore: update component statuses"
git push origin docs/update-component-statuses
echo "new_files=true" >> $GITHUB_ENV
fi
- name: Create PR
uses: actions/github-script@v6
if: env.new_files == 'true'
with:
script: |
github.rest.pulls.create({
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/cron-update-tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
- cron: "0 8 * * *"
workflow_dispatch:

env:
new_files: false

jobs:
cron-update-tokens:
runs-on: ubuntu-latest
Expand All @@ -31,17 +34,19 @@ jobs:
git add --all
if git diff-index --quiet HEAD; then
echo "No changes to tokens. Exiting."
exit 0
echo "new_files=false" >> $GITHUB_ENV
else
git checkout -b feat/update-palette-tokens
git commit -m "feat(tokens): update palette"
git push origin feat/update-palette-tokens
echo "new_files=true" >> $GITHUB_ENV
fi
env:
FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }}

- name: Create PR
uses: actions/github-script@v6
if: env.new_files == 'true'
with:
script: |
github.rest.pulls.create({
Expand Down

0 comments on commit 7a0a240

Please sign in to comment.