Skip to content

Commit ab75677

Browse files
committed
Update Actions workflows to avoid empty deployments
1 parent a8955cc commit ab75677

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.github/workflows/dashboard.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
name: Fetch data and update dashboard
33

44
on:
5-
# push:
6-
# branches: [ main ]
75
schedule:
86
- cron: '30 14 * * *' # Daily at 14:30 UTC (9:30 EST or 10:30 EDT)
97
workflow_dispatch:
108

119
jobs:
1210
build:
1311
runs-on: ubuntu-latest
12+
id: build_and_commit
13+
outputs:
14+
committed: ${{ steps.commit_and_push.outputs.committed }}
1415

1516
steps:
1617
- name: Check out repository
@@ -30,6 +31,7 @@ jobs:
3031
run: python content/dashboard/dashboard.py
3132

3233
- name: Commit and push updated charts and data
34+
id: commit_and_push
3335
run: |
3436
git config user.name "github-actions[bot]"
3537
git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -40,6 +42,8 @@ jobs:
4042
echo "Changes detected in generated files. Committing..."
4143
git commit -m "Update dashboard with newly released data"
4244
git push
45+
echo "committed=true" >> "$GITHUB_OUTPUT"
4346
else
4447
echo "No changes detected in generated files. Nothing to commit."
48+
echo "committed=false" >> "$GITHUB_OUTPUT"
4549
fi

.github/workflows/hugo.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ defaults:
3535

3636
jobs:
3737
# Build job
38-
build:
39-
# Ensure that the build job only runs for 'push', 'workflow_dispatch', or successful 'workflow_run' events
40-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
38+
build:
39+
# Ensure that the build job only runs for 'push', 'workflow_dispatch', or a successful 'workflow_run' that made a commit
40+
if: |
41+
github.event_name == 'push' ||
42+
github.event_name == 'workflow_dispatch' ||
43+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.jobs[0].outputs.committed == 'true')
4144
runs-on: ubuntu-latest
4245
env:
4346
HUGO_VERSION: 0.147.2
@@ -72,7 +75,11 @@ jobs:
7275

7376
# Deployment job
7477
deploy:
75-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
78+
# Ensure that the deploy job only runs for 'push', 'workflow_dispatch', or a successful 'workflow_run' that made a commit
79+
if: |
80+
github.event_name == 'push' ||
81+
github.event_name == 'workflow_dispatch' ||
82+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.jobs[0].outputs.committed == 'true')
7683
environment:
7784
name: github-pages
7885
url: ${{ steps.deployment.outputs.page_url }}

0 commit comments

Comments
 (0)