update-vote-results #457
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: update-vote-results | |
on: | |
workflow_dispatch: | |
inputs: | |
comment_id: | |
type: string | |
env: | |
GH_BOT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" | |
GH_BOT_NAME: "GitHub Action" | |
DENO_DIR: .deno-cache | |
REPO: commonhaus/commonhaus.github.io | |
permissions: {} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
actions: write | |
steps: | |
- name: Setup Deno environment | |
uses: denoland/setup-deno@v2 | |
with: | |
deno-version: v1.x | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache Deno dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.DENO_DIR }} | |
key: ${{ hashFiles('deno.lock') }} | |
- name: Git Config | |
run: | | |
git config user.name ${{ env.GH_BOT_NAME }} | |
git config user.email ${{ env.GH_BOT_EMAIL }} | |
- name: Git Vote Update | |
id: votes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
INPUT: ${{ github.event.inputs.comment_id }} | |
run: | | |
echo "Updating vote results..." | |
if [ -z "${INPUT}" ]; then | |
deno task repair | |
else | |
deno task votes "${INPUT}" | |
fi | |
git add -A -- ./site/_generated/votes | |
if git diff --quiet HEAD; then | |
echo "-- No changes -- " | |
else | |
git commit -am "🗳️ Auto-update GH Votes" | |
git pull --rebase | |
git push | |
echo "updated=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Push GH Pages | |
if: ${{ steps.votes.outputs.updated == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh workflow run -R commonhaus/commonhaus.github.io gh-pages.yml |