Create update.yml #13
Workflow file for this run
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: Build and test by Gradle | |
on: | |
schedule: | |
- cron: '0 0 1 * *' | |
pull_request: | |
branches: [ "*" ] | |
workflow_dispatch: | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '[email protected]' | |
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" | |
git fetch | |
git checkout main | |
git push origin --delete gh-actions-update || true | |
git checkout -b gh-actions-update | |
- name: Update tzot.json | |
run: docker compose up --build update | |
- name: Commit and push if new version found | |
run: | | |
set -eux | |
if [ -n "$(git diff)" ]; then | |
TZ_VERSION=$(cat gen/version) | |
git commit -am "Update tzot.json (${TZ_VERSION})" | |
git push | |
fi | |
- name: Create PR if new update found | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -eux | |
if [ -n "$(git diff)" ]; then | |
TZ_VERSION=$(cat gen/version) | |
gh pr create --title "Update tzot.json (${TZ_VERSION})" --body "Update tzot.json (${TZ_VERSION})" --base main --head gh-actions-update | |
fi |