Create update.yml #18
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 | |
env: | |
MAIN_BRANCH: "github-actions" | |
UPDATE_BRANCH: "github-actions-update" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Initialize branch | |
run: | | |
set -eux | |
#git config --global user.name 'GitHub Actions' | |
#git config --global user.email '[email protected]' | |
#git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}" | |
git fetch | |
git checkout "${MAIN_BRANCH}" | |
git push origin --delete "${UPDATE_BRANCH}" || true | |
git checkout -b "${UPDATE_BRANCH}" | |
- name: Update tzot.json | |
run: | | |
set -eux | |
docker compose up --build update | |
if [ -n "$(git diff)" ]; then | |
echo "NEW_VERSION_FOUND=true" >> "${GITHUB_ENV}" | |
echo "TZ_VERSION=$(cat /gen/version)" >> "${GITHUB_ENV}" | |
fi | |
- name: Commit and push if new version found | |
if: ${{ env.NEW_VERSION_FOUND == 'true' }} | |
run: | | |
set -eux | |
git commit -am "Update tzot.json (${TZ_VERSION})" | |
git push --set-upstream origin "${UPDATE_BRANCH}" | |
- name: Create PR if new update found | |
if: ${{ env.NEW_VERSION_FOUND == 'true' }} | |
run: | | |
set -eux | |
gh pr create --title "Update tzot.json (${TZ_VERSION})" --body "Update tzot.json (${TZ_VERSION})" --base main --head gh-actions-update |