Skip to content

Commit 9f74ee8

Browse files
committed
Tweak workflow
1 parent 92eecb0 commit 9f74ee8

File tree

1 file changed

+33
-36
lines changed

1 file changed

+33
-36
lines changed

.github/workflows/run_and_deploy.yml

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: Run and Deploy
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [main]
66
pull_request:
77
workflow_dispatch:
88
schedule:
9-
- cron: "0 0 * * *" # Every day at 00:00 UTC
9+
- cron: "0 0 * * *" # daily 00:00 UTC
1010

1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref }}
@@ -16,83 +16,80 @@ jobs:
1616
run_script:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- name: Checkout Repository
19+
- name: Checkout repository
2020
uses: actions/checkout@v6
2121
- name: Set up Python 3.14
2222
uses: actions/setup-python@v6
2323
with:
2424
python-version: "3.14"
2525
- name: Install dependencies
26-
run: python -m pip install tox
27-
- name: Run Script
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install tox
29+
- name: Run tests/build
2830
run: tox -e py314
2931
- name: Upload artifacts
3032
uses: actions/upload-artifact@v6
3133
with:
3234
name: files
3335
path: |
3436
timeline*
37+
if-no-files-found: error
3538

3639
deploy:
3740
needs: [run_script]
38-
if: |
39-
github.event_name != 'pull_request' && (
40-
github.ref_name == 'main' ||
41-
github.event_name == 'workflow_dispatch'
42-
)
41+
if: github.event_name != 'pull_request' && (github.ref_name == 'main' || github.event_name == 'workflow_dispatch')
4342
runs-on: ubuntu-latest
4443
permissions:
4544
contents: write
46-
env:
47-
RELEASE_TAG: daily-timeline
4845
steps:
49-
- name: Checkout Repository
46+
- name: Checkout repository (full history for tags)
5047
uses: actions/checkout@v6
5148
with:
5249
fetch-depth: 0
53-
- name: Get current date
50+
- name: Get current date (UTC)
5451
id: date
55-
run: echo "date=$(date +'%Y%m%d')" >> "$GITHUB_OUTPUT"
52+
run: echo "date=$(date -u +'%Y%m%d')" >> "$GITHUB_OUTPUT"
5653
- name: Download workflow artifacts
5754
uses: actions/download-artifact@v7
5855
with:
5956
name: files
6057
path: ${{ runner.temp }}/files
61-
- name: Display structure of downloaded files
62-
run: ls -R
63-
working-directory: ${{ runner.temp }}/files
64-
- name: Move/force-update the release tag to this commit
58+
- name: Display downloaded files
59+
run: ls -R "${{ runner.temp }}/files"
60+
# Keep ONE release by keeping ONE tag that always points at the latest main commit.
61+
- name: Update rolling tag (nightly)
6562
run: |
66-
git config user.name "github-actions[bot]"
67-
git config user.email "github-actions[bot]@users.noreply.github.com"
68-
git tag -f "${RELEASE_TAG}" "${GITHUB_SHA}"
69-
git push origin -f "refs/tags/${RELEASE_TAG}"
70-
- name: Create/update release and upload assets
63+
git tag -f nightly
64+
git push --force origin refs/tags/nightly
65+
- name: Create/update GitHub release (nightly)
7166
uses: ncipollo/release-action@v1
7267
with:
73-
name: Timeline created on ${{ steps.date.outputs.date }}
74-
tag: ${{ env.RELEASE_TAG }}
75-
artifacts: "${{ runner.temp }}/files/*"
68+
tag: nightly
69+
name: Timeline (nightly) — ${{ steps.date.outputs.date }}
70+
artifacts: ${{ runner.temp }}/files/*
71+
allowUpdates: true
7672
replacesArtifacts: true
7773
makeLatest: true
7874
artifactErrorsFailBuild: true
79-
allowUpdates: true
80-
# token omitted on purpose; defaults to github.token (GITHUB_TOKEN)
81-
- name: Checkout csv-to-html-table repository
75+
- name: Checkout csv-to-html-table
8276
uses: actions/checkout@v6
8377
with:
8478
repository: derekeder/csv-to-html-table
8579
ref: master
8680
path: csv_to_html
87-
- name: Move files into csv_to_html
81+
- name: Stage site content
82+
shell: bash
8883
run: |
89-
mv "${{ runner.temp }}/files/timeline_${{ steps.date.outputs.date }}.csv" \
90-
"${GITHUB_WORKSPACE}/csv_to_html/data/timeline.csv"
91-
mv "${GITHUB_WORKSPACE}/index.html" \
92-
"${GITHUB_WORKSPACE}/csv_to_html/"
84+
set -euxo pipefail
85+
cp "${{ runner.temp }}/files/timeline_${{ steps.date.outputs.date }}.csv" \
86+
"$GITHUB_WORKSPACE/csv_to_html/data/timeline.csv"
87+
cp "$GITHUB_WORKSPACE/index.html" \
88+
"$GITHUB_WORKSPACE/csv_to_html/index.html"
9389
- name: Deploy to GitHub Pages (gh-pages branch)
9490
uses: peaceiris/actions-gh-pages@v4
9591
with:
9692
github_token: ${{ secrets.GITHUB_TOKEN }}
97-
publish_dir: "${GITHUB_WORKSPACE}/csv_to_html/"
93+
publish_branch: gh-pages
94+
publish_dir: ./csv_to_html
9895
force_orphan: true

0 commit comments

Comments
 (0)