Last active
July 25, 2024 15:14
-
-
Save jclusso/d8502e2f80dfc22d130c015f88dda02e to your computer and use it in GitHub Desktop.
Update Campfire with a GitHub Action that creates a PR.
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 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 "[email protected]" | |
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