build #30286
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 | |
on: | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: "0 * * * *" | |
defaults: | |
run: | |
# NOTE: Default option does not include `-o pipefail` as documented | |
# unless explicitly specifying the `bash` shell. | |
# https://github.com/actions/runner/issues/353 | |
shell: bash | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 3 | |
steps: | |
- name: Checkout branch | |
uses: actions/[email protected] | |
- name: Set up Go | |
uses: actions/[email protected] | |
- name: Install blt | |
run: | | |
go install \ | |
github.com/loozhengyuan/blt/cmd/blt@latest | |
- name: Build blocklist | |
run: | | |
blt build .blt.yaml | |
- name: Generate checksums | |
run: | | |
sha256sum dist/*.txt > dist/SHA256SUMS | |
# NOTE: The commit email address should be the canonical no-reply email address | |
# used by the `github-actions[bot]` bot user. | |
# https://api.github.com/users/github-actions%5Bbot%5D | |
# https://github.community/t/github-actions-bot-email-address/17204/6 | |
- name: Set up git config | |
run: | | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
- name: Stage changes | |
run: | | |
git add dist/ | |
- name: Diff staged changes | |
run: | | |
git diff --staged | |
# NOTE: The `git commit` command returns a non-zero exit code if there are no changes | |
# to commit. Using the `git diff-index` command checks if there are changes in the | |
# index (i.e. the staging area). | |
- name: Commit changes | |
run: | | |
git diff-index --quiet --cached HEAD || git commit -m "chore: rebuild blocklist" | |
- name: Push commit | |
# NOTE: We only want changes to updated on the scheduled runs | |
if: ${{ github.event_name == 'schedule' }} | |
run: | | |
git push |