Skip to content

Fix pr number in workflow dispatch #59

Fix pr number in workflow dispatch

Fix pr number in workflow dispatch #59

name: Generate PR cache by copying main
on:
pull_request:
types:
- opened
- reopened
branches:
- main
workflow_dispatch:
inputs:
pr_number:
description: "Initialize the cache for PR#:"
type: string
defaults:
run:
shell: bash -l {0}
env:
PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && github.event.number || inputs.pr_number }}
jobs:
preprocess:
runs-on: ubuntu-latest
steps:
- name: Checkout deployment branch
uses: actions/checkout@v4
with:
ref: _cookbook_data_main
clean: false
- name: Copy cache from main to PR branch
id: copyCache
run: |
git config user.name github-actions
git config user.email [email protected]
git push origin HEAD:_cookbook_data_PR${{ env.PR_NUMBER }}
- name: Add descriptive comment to PR
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ env.PR_NUMBER }}
message: >
This repository caches data generated from notebooks stored in other
repositories in the `_cookbook_data_*` branches. Regenerating this
cache takes about half an hour, so it is not done automatically in
PRs. The current value of the cache from the `main` branch has been
copied over to this PR's cache.
To regenerate the cache for this PR, create a comment on this PR
consisting only of the string:
```
/regenerate-cache
```
- name: Add instructions to run manually on PR from external contributors
uses: thollander/actions-comment-pull-request@v3
if: failure() && steps.copyCache.outcome == 'failure'
with:
pr-number: ${{ env.PR_NUMBER }}
message: >
This repository caches data generated from notebooks stored in other
repositories in the `_cookbook_data_*` branches. Regenerating this
cache takes about half an hour, so it is not done automatically in
PRs.
The current value of the cache from the `main` branch was not
successfully copied over to this PR's cache, most likely because it
is from an external contributor. A maintainer can [manually trigger]
the workflow here:
https://github.com/openforcefield/openff-docs/actions/workflows/cookbook_pr_opened.yaml
[manually trigger]: https://github.com/openforcefield/openff-docs/actions/workflows/cookbook_pr_opened.yaml