Create PR to update external_studies
test code
#322
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: "Create PR to update `external_studies` test code" | |
on: | |
workflow_dispatch: | |
# Once a week on Sunday afternoon | |
schedule: | |
- cron: "21 17 * * 0" | |
jobs: | |
create_external_studies_pr: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: opensafely-core/setup-action@v1 | |
with: | |
install-just: true | |
python-version: "3.11" | |
- name: Update vendored copies of external study code | |
run: just update-external-studies | |
# These are problematic (in particular the flake8 hook doesn't respect | |
# the `.flake8` config file) and unnecessary as all the checks will get | |
# run on the PR anyway | |
- name: Disable pre-commit hooks | |
run: git config core.hooksPath /dev/null | |
- name: Create a Pull Request if there are any changes | |
id: create_pr | |
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 | |
with: | |
add-paths: tests/acceptance/external_studies/* | |
branch: bot/update-external-studies | |
base: main | |
author: "opensafely-github-bot <[email protected]>" | |
committer: "opensafely-github-bot <[email protected]>" | |
commit-message: "chore: Update `external_studies` test code" | |
title: "Update `external_studies` test code" | |
body: | | |
To get tests to run on this PR there's an odd workflow: | |
- Approve it | |
- Close it | |
- Re-open it | |
- Re-enable automerge | |
You can read more on why this is needed in the `create-pull-request` [docs][1]. | |
[1]: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs | |
# The PR will still require manual approval, this just reduces it to a one-click process | |
- name: Enable automerge | |
if: steps.create_pr.outputs.pull-request-operation == 'created' | |
run: gh pr merge --auto --squash ${{ steps.create_pr.outputs.pull-request-number }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |