Skip to content

Commit

Permalink
CI: Add cron workflow for gTLD update PRs. (#513)
Browse files Browse the repository at this point in the history
Previously we used a separate repo with a bash script[0] hooked up to
a bot github user[1] in a Travis CI cron build to automatically create
PRs updating ZLint TLD data on a periodic basis.

Now that we're using Github Actions we can make things much simpler and
self-contained.

This commit adds a `tld-update.yml` workflow that uses
a create-pull-request Github action to replace the separate repo/bash
script/bot user approach.

Not only does this let us delete the bot user's write access to the
ZLint repo but it's also a smarter integration overall and won't
recreate the same PR over and over if it isn't merged right away. Lastly
the Github Actions cron schedule is more flexible so we can run the new
action once every hour instead of just once a day like the Travis
version.

[0]: https://github.com/cpu/zlint-autopull/blob/master/autopull
[1]: https://github.com/tld-update-bot
[2]: https://github.com/peter-evans/create-pull-request
  • Loading branch information
cpu committed Nov 30, 2020
1 parent fe65bae commit 12dfc18
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/tld-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: tld-update
on:
schedule:
# Run every hour, at the 15 minute mark. E.g.
# 2020-11-29 00:15:00 UTC, 2020-11-29 01:15:00 UTC, 2020-11-29 02:15:00 UTC
- cron: '15 * * * *'
jobs:
zlint-gtld-update:
name: Check for TLD data updates
runs-on: ubuntu-latest
steps:

- name: Check out code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.15

- name: Set current date as env variable
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S %Z')" >> $GITHUB_ENV

- name: Install zlint-gtld-update
run: go install ./cmd/zlint-gtld-update/...
working-directory: v3

- name: Run go-generate
run: go generate ./...
working-directory: v3

- name: Create pull-request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
commit-message: "util: gtld_map autopull updates for ${{ env.NOW }}"
title: "util: gtld_map autopull updates for ${{ env.NOW }}"
body: "ZLint gTLD data updates from `go generate ./...` for ${{ env.NOW }}."
labels: tld-update
branch: zlint-gtld-update
delete-branch: true

- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

0 comments on commit 12dfc18

Please sign in to comment.