Skip to content

Commit Recent Twilogs #510

Commit Recent Twilogs

Commit Recent Twilogs #510

name: Commit Recent Twilogs
on:
workflow_dispatch:
schedule:
# Run every 4 hours
- cron: "23 */4 * * *"
permissions:
contents: write
id-token: write
concurrency:
group: commit-recent-twilogs
cancel-in-progress: false
jobs:
commit-recent-twilogs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
key: v1-${{ hashFiles('package-lock.json') }}-
restore-keys: |
v1-
path: |
node_modules
- uses: actions/setup-node@v3
with:
node-version: "16"
- run: npm ci
- name: Setup git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Fetch, commit and push if anything new
id: fetch
run: |
if npm run fetch_recent_twilogs; then
git diff --name-only HEAD~ | grep "\-twilogs.json" | xargs npm run build_twilog_meilisearch_index
git push origin HEAD:master
echo "has_new_twilogs=true" >> "$GITHUB_OUTPUT"
fi
env:
MY_TWILOG_CSV_URL: ${{ secrets.MY_TWILOG_CSV_URL }}
MEILISEARCH_HOST: ${{ secrets.MEILISEARCH_HOST }}
MEILISEARCH_ADMIN_KEY: ${{ secrets.MEILISEARCH_ADMIN_KEY }}
outputs:
has_new_twilogs: ${{ steps.fetch.outputs.has_new_twilogs }}
deploy:
needs: commit-recent-twilogs
if: needs.commit-recent-twilogs.outputs.has_new_twilogs
uses: ./.github/workflows/gh-pages.yml
secrets: inherit
permissions:
contents: read
pages: write
id-token: write