-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,10 @@ on: | |
workflow_dispatch: | ||
|
||
jobs: | ||
update-tzdata: | ||
check-pr-exists: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
pr_exists: ${{ steps.check_pr_exists.outputs.pr_exists }} | ||
steps: | ||
- name: Check if PR already exists | ||
id: check_pr_exists | ||
|
@@ -20,10 +21,20 @@ jobs: | |
list --search "Update tzdata to version" \ | ||
--json number --jq '.[] | .number') | ||
if [ -n "$PR_EXISTS" ]; then | ||
echo "A PR updating the tzdata version already exists, see http://github.com/python/tzdata/pulls/${PR_EXISTS}" | ||
echo "A PR updating the tzdata version already exists: https://github.com/python/tzdata/pulls/${PR_EXISTS}" | ||
echo "::set-output name=pr_exists::true" | ||
exit 0 | ||
else | ||
echo "::set-output name=pr_exists::false" | ||
fi | ||
check-for-updates: | ||
runs-on: ubuntu-latest | ||
needs: check-pr-exists | ||
if: needs.check-pr-exists.outputs.pr_exists == 'false' # Run only if no PR exists | ||
outputs: | ||
changes_detected: ${{ steps.check_changes.outputs.changes_detected }} | ||
steps: | ||
- name: Check out repository (shallow) | ||
uses: actions/checkout@v3 | ||
with: | ||
|
@@ -42,7 +53,7 @@ jobs: | |
- name: Run tox update | ||
run: tox -e update | ||
|
||
- name: Check for repository changes | ||
- name: Check for repository changes and commit | ||
id: check_changes | ||
run: | | ||
git config --global user.email "[email protected]" | ||
|
@@ -51,6 +62,7 @@ jobs: | |
# Check for changes | ||
if git diff --quiet; then | ||
echo "No changes detected." | ||
echo "::set-output name=changes_detected::false" | ||
exit 0 | ||
fi | ||
|
@@ -76,15 +88,18 @@ jobs: | |
echo "TZDATA_VERSION=$TZDATA_VERSION" >> $GITHUB_ENV | ||
echo "TZDATA_NEWS=$TZDATA_NEWS" >> $GITHUB_ENV | ||
- name: Commit and push changes | ||
if: steps.check_changes.outcome == 'success' | ||
run: | | ||
git add . | ||
git commit -m "Update tzdata to version $TZDATA_VERSION" | ||
git push origin HEAD | ||
echo "::set-output name=changes_detected::true" | ||
create-pr: | ||
runs-on: ubuntu-latest | ||
needs: check-for-updates | ||
if: needs.check-for-updates.outputs.changes_detected == 'true' # Run only if changes are detected | ||
steps: | ||
- name: Create pull request | ||
if: steps.check_pr_exists.outcome == 'success' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
|