Skip to content

Update TimeZone Database #94

Update TimeZone Database

Update TimeZone Database #94

name: Update TimeZone Database
permissions:
contents: write
pull-requests: write
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Branch
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git checkout -b update-from-IANA-${{ github.run_id }}
- name: Run UpdateToLatestVersion
run: |
rm -r src/System.Runtime.TimeZoneData/data
git rm -r src/System.Runtime.TimeZoneData/data
./dotnet.sh build src/System.Runtime.TimeZoneData /t:UpdateToLatestVersion
git add src/System.Runtime.TimeZoneData
- name: Check for changes
id: check_changes
run: |
echo "has_changes=$(git diff-index --quiet HEAD && echo false || echo true)" >> $GITHUB_OUTPUT
- name: Commit Update
run: |
echo steps.check_changes.outputs.has_changes=${{steps.check_changes.outputs.has_changes}}
if ${{steps.check_changes.outputs.has_changes}} == 'true'; then
git commit -m "Automated update of IANA time zone data"
git push --set-upstream origin update-from-IANA-${{ github.run_id }}
else
echo "No changes detected."
fi
- name: Create PR
if: steps.check_changes.outputs.has_changes == 'true'
uses: actions/github-script@v7
with:
script: |
const { data: pullRequest } = await github.rest.pulls.create({
base: context.ref,
head: "update-from-IANA-${{ github.run_id }}",
owner: context.repo.owner,
repo: context.repo.repo,
title: '🕑🕒🕓 Time zone update',
body: 'IANA has updated tzdb. See https://data.iana.org/time-zones'
});
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pullRequest.number,
reviewers: ["lewing"]
});
return pullRequest.number;