From 4d029943c3b6e2171ecc9c26e75fe91382716567 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 23 Jan 2022 22:00:05 +0900 Subject: [PATCH] Automatically creates PR when no_atomic.rs needs to be updated --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71b54912b..2d09d7b47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,17 +100,40 @@ jobs: run: ./ci/dependencies.sh # When this job failed, run ci/no_atomic.sh and commit result changes. - # TODO(taiki-e): Ideally, this should be automated using a bot that creates - # PR when failed, but there is no bandwidth to implement it - # right now... codegen: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write steps: - uses: actions/checkout@v2 - name: Install Rust run: rustup update nightly && rustup default nightly - run: ci/no_atomic.sh - - run: git diff --exit-code + - run: git add -N . && git diff --exit-code + if: github.event_name != 'schedule' && !(github.event_name == 'push' && github.ref == 'refs/heads/main') + - id: diff + run: | + git config user.name "Taiki Endo" + git config user.email "te316e89@gmail.com" + git add -N . + if ! git diff --exit-code; then + git add . + git commit -m "Update no_atomic.rs" + echo "::set-output name=success::false" + fi + if: github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main' + - uses: taiki-e/create-pull-request@v3 + with: + title: Update no_atomic.rs + body: | + Auto-generated by [create-pull-request][1] + [Please close and immediately reopen this pull request to run CI.][2] + + [1]: https://github.com/peter-evans/create-pull-request + [2]: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs + branch: update-no-atomic-sh + if: (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false' # Check formatting. rustfmt: