btcpay-contribute/.github/workflows/fetch-issues.yml
2026-03-19 16:50:23 +01:00

94 lines
2.5 KiB
YAML

name: Fetch Issues
on:
schedule:
- cron: '0 */6 * * *' # every 6 hours
workflow_dispatch: # manual trigger from GitHub UI
# Prevent overlapping scheduled runs
concurrency:
group: fetch-issues
cancel-in-progress: false
jobs:
fetch:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
changed: ${{ steps.fetch.outputs.changed }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 20
cache: npm
- run: npm ci
- name: Fetch issues from GitHub
id: fetch
shell: bash
run: |
set +e
node scripts/fetch-issues.js
code=$?
if [ $code -eq 0 ]; then
echo "changed=true" >> $GITHUB_OUTPUT
elif [ $code -eq 1 ]; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Fetch script failed with exit code $code — check logs above"
exit $code
fi
env:
ORG_GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }}
- name: Commit and push if data changed
if: steps.fetch.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add public/data/issues.json
git commit -m "chore: refresh issues data"
git pull --rebase origin main
git push
build:
needs: fetch
if: needs.fetch.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: main # ensure we get the just-pushed commit
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
id: deployment