Update #302
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
--- | |
# Automatically builds new TZJData artifacts and creates a PR with the associated | |
# changes to the `Project.toml` and `Artifacts.toml`. Once the PR has been merged the | |
# `Release.yaml` workflow will generate a GitHub release with the assets to fufill the | |
# artifact URLs within the `Artifacts.toml`. | |
name: Update | |
on: | |
pull_request: | |
paths: | |
- .github/workflows/Update.yaml | |
schedule: | |
- cron: "44 9 * * *" # Every day at 09:44 UTC | |
workflow_dispatch: {} | |
jobs: | |
artifacts: | |
name: Artifacts | |
runs-on: ubuntu-latest | |
# These permissions are needed to: | |
# - Create PRs: https://github.com/marketplace/actions/create-pull-request#workflow-permissions | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
JULIA_PROJECT: gen | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha || 'main' }} | |
- uses: julia-actions/setup-julia@v1 | |
with: | |
version: "1" | |
- uses: julia-actions/cache@v1 | |
- name: Instantiate | |
shell: julia --color=yes {0} | |
run: | | |
using Pkg | |
Pkg.instantiate() | |
- name: Build tzdata | |
id: build | |
shell: julia --color=yes {0} | |
run: | | |
include(joinpath(pwd(), "gen", "make.jl")) | |
if is_pkg_tzdata_version_outdated() | |
(; tarball_path, tarball_sha256, new_version, commit_message) = update_tzdata() | |
key = basename(tarball_path) * "-" * tarball_sha256 | |
@show key tarball_path commit_message | |
open(ENV["GITHUB_OUTPUT"], "a") do io | |
println(io, "updated=true") | |
println(io, "key=$key") | |
println(io, "tarball_path=$tarball_path") | |
println(io, "commit_message=$commit_message") | |
end | |
else | |
open(ENV["GITHUB_OUTPUT"], "a") do io | |
println(io, "updated=false") | |
end | |
end | |
println("workflow_ref=${{ github.workflow_ref }}") | |
- run: git diff | |
# Store the Julia artifact tarball as a GitHub actions artifact. This will allow us to retrieve this | |
# tarball from other workflows. | |
- uses: actions/upload-artifact@v4 | |
if: ${{ steps.build.outputs.updated == 'true' }} | |
id: action-artifact | |
with: | |
name: ${{ steps.build.outputs.key }} | |
path: ${{ steps.build.outputs.tarball_path }} | |
# We need to introduce a slight delay after we upload the artifact to ensure the CI | |
# checks run for the PR can locate the artifact. | |
- name: Delay PR creation | |
if: ${{ steps.build.outputs.updated == 'true' }} | |
run: sleep 15 | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
if: ${{ steps.build.outputs.updated == 'true' }} | |
with: | |
base: main # Shouldn't be required for `workflow_dispatch` | |
title: ${{ steps.build.outputs.commit_message }} | |
body: >- | |
An automated PR generated by the ${{ github.workflow }} workflow. | |
add-paths: | | |
Project.toml | |
Artifacts.toml | |
commit-message: ${{ steps.build.outputs.commit_message }} | |
branch: gh/update-tzdata | |
token: ${{ secrets.TZJDATA_UPDATE_TOKEN }} # TODO: Fine-grained token expires | |
# Work around having GitHub suspend the scheduled workflow if there is no commit activity | |
# for the past 60 days. As this repo doesn't get much activity beyond artifact updates | |
# this can be quite annoying. | |
keepalive: | |
name: Keepalive | |
runs-on: ubuntu-latest | |
# These permissions are needed to: | |
# - Keep the workflow alive: https://github.com/marketplace/actions/keepalive-workflow#github-api-keepalive-workflow---default-for-github-actions-users | |
permissions: | |
actions: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: gautamkrishnar/keepalive-workflow@v2 |