Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interactive-templates update workflow #4442

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/update-interactive-templates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: "Create PR to update interactive-templates"

on:
workflow_dispatch:
schedule:
- cron: "25 13 * * *"

jobs:
create_job_server_pr:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: opensafely-core/setup-action@v1
with:
install-just: true
python-version: "3.12"

- name: Update requirement to latest
run: |
just update-interactive-templates
updated_version="$(sed -n 's|^interactive_templates@https://github.com/opensafely-core/interactive-templates/archive/refs/tags/\(v[0-9.].*\).zip$|\1|p' requirements.prod.in)"
echo "UPDATED_VERSION=$updated_version" >> "$GITHUB_ENV"

- name: Create a Pull Request if there are any changes
id: create_pr
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
token: "${{ secrets.JOB_SERVER_PR_TOKEN }}"
add-paths: requirements.*
base: main
branch: bot/update-interactive-templates
author: "opensafely-github-bot <[email protected]>"
committer: "opensafely-github-bot <[email protected]>"
commit-message: "Bump interactive-templates to ${{ env.UPDATED_VERSION }}"
title: "Update interactive templates to ${{ env.UPDATED_VERSION }}"
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

- name: Enable automerge
if: steps.create_pr.outputs.pull-request-operation == 'created'
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }} "
run: gh pr merge --merge --auto --squash ${{ steps.create_pr.outputs.pull-request-number }}