Skip to content

Auto Update

Auto Update #383

Workflow file for this run

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: libraries/bzlmodrio-phoenix
# Checkout gentool
- uses: actions/checkout@v4
with:
repository: 'bzlmodRio/gentool.git'
fetch-depth: 0
path: gentool
ref: refactor_dev
# Checkout bzlmodrio-allwpilib
- uses: actions/checkout@v4
with:
repository: 'bzlmodRio/bzlmodrio-allwpilib.git'
fetch-depth: 0
path: libraries/bzlmodrio-phoenix/../../libraries/bzlmodRio-allwpilib
ref: main
# Checkout bzlmodrio-phoenix6
- uses: actions/checkout@v4
with:
repository: 'bzlmodRio/bzlmodrio-phoenix6.git'
fetch-depth: 0
path: libraries/bzlmodrio-phoenix/../../libraries/bzlmodRio-phoenix6
ref: main
# Checkout backdoor generation of wpilibsuite libraries
- uses: actions/checkout@v4
with:
repository: 'bzlmodRio/wpilibsuite_generator.git'
fetch-depth: 0
path: libraries/bzlmodrio-choreolib/../../wpilibsuite_gen
ref: main
- 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: libraries/bzlmodrio-phoenix/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: libraries/bzlmodrio-phoenix/generate
- name: Store new version
run: echo "NEW_VERSION=$(bazel run //:get_version)" >> $GITHUB_ENV
working-directory: libraries/bzlmodrio-phoenix/generate
# Create pull requests
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
env:
GITHUB_TOKEN: ${{ secrets.AUTO_UPDATE_KEY }}
with:
path: libraries/bzlmodrio-phoenix
base: main
token: ${{ secrets.AUTO_UPDATE_KEY }}
branch: autoupdate_${{ env.NEW_VERSION }}
title: "Auto Update to '${{ env.NEW_VERSION }}'"