Skip to content

Instantly share code, notes, and snippets.

@jclusso
Last active February 5, 2024 17:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jclusso/d8502e2f80dfc22d130c015f88dda02e to your computer and use it in GitHub Desktop.
Save jclusso/d8502e2f80dfc22d130c015f88dda02e to your computer and use it in GitHub Desktop.
Update Campfire with a GitHub Action that creates a PR.
name: Update Campfire Source
on:
schedule:
- cron: "0 4 * * *"
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Download Update & Create Branch
run: |
find . -mindepth 1 -maxdepth 1 ! -name .git ! -name . ! -name .. ! -path './.github' ! -path './.github/*' -exec rm -rf {} +
curl -o download.zip https://auth.once.com/download/${{ secrets.PURCHASE_TOKEN }}
unzip -o download.zip
rm download.zip
git config --local user.email "github-actions@users.noreply.github.com"
git config --local user.name "github-actions"
BRANCH_NAME="update-source-$(date +%F)"
git checkout -b $BRANCH_NAME
git add .
if git diff --staged --quiet; then
echo "No changes to commit."
echo "has_changes=false" >> $GITHUB_ENV
else
echo "Changes detected."
echo "has_changes=true" >> $GITHUB_ENV
git commit -m "Updated source files $(date +%F)"
git push origin $BRANCH_NAME
fi
- name: Create Pull Request
if: env.has_changes == 'true'
run: gh pr create --fill
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment