Auto Update #231
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: Auto Update | |
on: | |
workflow_dispatch: | |
schedule: | |
# Check everyday at 20:00 UTC | |
- cron: '0 20 * * *' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
auto_update_module: | |
name: "Auto Update Module" | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Set up Go 1.20.x | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.20.x | |
cache: false | |
id: go | |
- uses: actions/checkout@v4 | |
- name: Install Buildifier | |
run: | | |
cd $(mktemp -d) | |
GO111MODULE=on go install github.com/bazelbuild/buildtools/buildifier@latest | |
# Checkout repository | |
- uses: actions/checkout@v4 | |
with: | |
path: rules/rules_bzlmodrio_toolchains | |
# Checkout gentool | |
- uses: actions/checkout@v4 | |
with: | |
repository: 'bzlmodRio/gentool.git' | |
fetch-depth: 0 | |
path: gentool | |
ref: refactor_dev | |
- name: Setup Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/bzlmod_cache/*.sha256 | |
key: ${{ runner.os }}-${{ hashFiles('**/generate/**') }} | |
restore-keys: | | |
${{ runner.os }}- | |
${{ runner.os }} | |
# Run update | |
- name: Run update | |
run: bazel run //:auto_update | |
working-directory: rules/rules_bzlmodrio_toolchains/generate | |
- name: Generate if changed | |
run: | | |
if [[ $(git --no-pager diff --exit-code HEAD) != '' ]]; then | |
echo "Something changed, need to re-generate" | |
bazel run //:generate | |
buildifier -warnings all --lint=fix -r .. | |
cd .. | |
bazel build //... --nobuild --enable_bzlmod --lockfile_mode=update -k || true | |
cd tests | |
bazel build //... --nobuild --enable_bzlmod --lockfile_mode=update -k || true | |
# Pull requests won't be created if the github actions change. Since for this | |
# We mostly care about the actual code changes, we will just revert those files | |
git checkout ../.github/workflows | |
else | |
echo "No changes!" | |
fi; | |
working-directory: rules/rules_bzlmodrio_toolchains/generate | |
- name: Store new version | |
run: echo "NEW_VERSION=$(bazel run //:get_version)" >> $GITHUB_ENV | |
working-directory: rules/rules_bzlmodrio_toolchains/generate | |
# Create pull requests | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.AUTO_UPDATE_KEY }} | |
with: | |
path: rules/rules_bzlmodrio_toolchains | |
base: main | |
token: ${{ secrets.AUTO_UPDATE_KEY }} | |
branch: autoupdate_${{ env.NEW_VERSION }} | |
title: "Auto Update to '${{ env.NEW_VERSION }}'" |