Skip to content

Commit

Permalink
Merge pull request #30 from carpentries-incubator/update-workflows-ve…
Browse files Browse the repository at this point in the history
…rsion-0.11.1

Update Workflows to Version 0.11.1
  • Loading branch information
jbkieffer authored Dec 6, 2022
2 parents ffb72b3 + 409f0e6 commit 0636f4c
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 55 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,11 @@ This workflow has two caches; one cache is for the lesson infrastructure and
the other is for the the lesson dependencies if the lesson contains rendered
content. These caches are invalidated by new versions of the infrastructure and
the `renv.lock` file, respectively. If there is a problem with the cache,
manual invaliation is necessary and can be done by setting the `CACHE_VERSION`
secret to the current date.

### Deploy to AWS (deploy-aws.yaml)

If you have an AWS bucket that is set up to deploy the site from a folder, this
workflow will deploy the site to that folder after `01 Build and Deploy` runs.
It can also be triggered manually.

Note: for this to work, you must have the `AWS_S3_BUCKET`, `AWS_ACCESS_KEY_ID`,
and `AWS_SECRET_ACCESS_KEY` in your repository secrets. If any of these are
missing, the workflow will not run.
manual invaliation is necessary. You will need maintain access to the repository
and you can either go to the actions tab and [click on the caches button to find
and invalidate the failing cache](https://github.blog/changelog/2022-10-20-manage-caches-in-your-actions-workflows-from-web-interface/)
or by setting the `CACHE_VERSION` secret to the current date (which will
invalidate all of the caches).

## Updates

Expand Down Expand Up @@ -96,24 +89,25 @@ will do the following:
1. check the recorded version of sandpaper against the current version on github
2. update the files if there is a difference in versions

After the files are updated, a pull request is created if there are any changes.
Maintainers are encouraged to review the changes and accept the pull request.
After the files are updated, if there are any changes, they are pushed to a
branch called `update/workflows` and a pull request is created. Maintainers are
encouraged to review the changes and accept the pull request if the outputs
are okay.

This update is run ~~weekly or~~ on demand.

TODO:
- perform check if a pull request exists before creating pull request

### 03 Maintain: Update Pacakge Cache (update-cache.yaml)

For lessons that have generated content, we use {renv} to ensure that the output
is stable. This is controlled by a single lockfile which documents the packages
needed for the lesson and the version numbers.
needed for the lesson and the version numbers. This workflow is skipped in
lessons that do not have generated content.

Because the lessons need to remain current with the package ecosystem, it's a
good idea to make sure these packages can be updated periodically. The
update cache workflow will do this by checking for updates, applying them and
creating a pull request with _only the lockfile changed_.
update cache workflow will do this by checking for updates, applying them in a
branch called `updates/packages` and creating a pull request with _only the
lockfile changed_.

From here, the markdown documents will be rebuilt and you can inspect what has
changed based on how the packages have updated.
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/pr-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
id: get-pr
run: |
unzip pr.zip
echo "::set-output name=NUM::$(<./NR)"
echo "NUM=$(<./NR)" >> $GITHUB_OUTPUT
- name: "Fail if PR number was not present"
id: bad-pr
Expand All @@ -48,7 +48,9 @@ jobs:
- name: "Get Invalid Hashes File"
id: hash
run: |
echo "::set-output name=json::"$(curl -sL https://files.carpentries.org/invalid-hashes.json)
echo "json<<EOF
$(curl -sL https://files.carpentries.org/invalid-hashes.json)
EOF" >> $GITHUB_OUTPUT
- name: "Check PR"
id: check-pr
if: ${{ steps.dl.outputs.success == 'true' }}
Expand All @@ -72,7 +74,7 @@ jobs:
NR: ${{ needs.test-pr.outputs.number }}
steps:
- name: 'Checkout md outputs'
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3
with:
ref: md-outputs
path: built
Expand All @@ -98,9 +100,9 @@ jobs:
git checkout --orphan md-outputs-PR-${NR}
git add -A
git commit -m "source commit: ${CURR_HEAD}"
ls -A | grep -v '^.git' | xargs rm -r
ls -A | grep -v '^.git$' | xargs rm -r
cd ..
unzip -d built built.zip
unzip -o -d built built.zip
cd built
git add -A
git commit --allow-empty -m "differences for PR #${NR}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-post-remove-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
id: get-pr
run: |
unzip pr.zip
echo "::set-output name=NUM::$(<./NUM)"
echo "NUM=$(<./NUM)" >> $GITHUB_OUTPUT
- name: 'Remove branch'
uses: carpentries/actions/remove-branch@main
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pr-preflight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
- name: "Get Invalid Hashes File"
id: hash
run: |
echo "::set-output name=json::"$(curl -sL https://files.carpentries.org/invalid-hashes.json)
echo "json<<EOF
$(curl -sL https://files.carpentries.org/invalid-hashes.json)
EOF" >> $GITHUB_OUTPUT
- name: "Check PR"
id: check-pr
uses: carpentries/actions/check-valid-pr@main
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pr-receive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ jobs:
- name: "Get Invalid Hashes File"
id: hash
run: |
echo "::set-output name=json::"$(curl -sL https://files.carpentries.org/invalid-hashes.json)
echo "json<<EOF
$(curl -sL https://files.carpentries.org/invalid-hashes.json)
EOF" >> $GITHUB_OUTPUT
- name: "echo output"
run: |
echo ${{ steps.hash.outputs.json }}
echo "${{ steps.hash.outputs.json }}"
- name: "Check PR"
id: check-pr
uses: carpentries/actions/check-valid-pr@main
Expand All @@ -52,10 +54,10 @@ jobs:
MD: ${{ github.workspace }}/site/built
steps:
- name: "Check Out Main Branch"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: "Check Out Staging Branch"
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: md-outputs
path: ${{ env.MD }}
Expand All @@ -68,8 +70,6 @@ jobs:

- name: "Set up Pandoc"
uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "2.11.4"

- name: "Setup Lesson Engine"
uses: carpentries/actions/setup-sandpaper@main
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/sandpaper-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
steps:

- name: "Checkout Lesson"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: "Set up R"
uses: r-lib/actions/setup-r@v2
Expand All @@ -42,8 +42,6 @@ jobs:

- name: "Set up Pandoc"
uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "2.11.4"

- name: "Setup Lesson Engine"
uses: carpentries/actions/setup-sandpaper@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sandpaper-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.6
0.11.1
26 changes: 13 additions & 13 deletions .github/workflows/update-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
- id: check
run: |
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
echo "::set-output name=ok::true"
echo "ok=true" >> $GITHUB_OUTPUT
echo "Running on request"
# using single brackets here to avoid 08 being interpreted as octal
# https://github.com/carpentries/sandpaper/issues/250
elif [ `date +%d` -le 7 ]; then
# If the Tuesday lands in the first week of the month, run it
echo "::set-output name=ok::true"
echo "ok=true" >> $GITHUB_OUTPUT
echo "Running on schedule"
else
echo "::set-output name=ok::false"
echo "ok=false" >> $GITHUB_OUTPUT
echo "Not Running Today"
fi
Expand All @@ -43,11 +43,11 @@ jobs:
needed: ${{ steps.renv.outputs.exists }}
steps:
- name: "Checkout Lesson"
uses: actions/checkout@v2
uses: actions/checkout@v3
- id: renv
run: |
if [[ -d renv ]]; then
echo "::set-output name=exists::true"
echo "exists=true" >> $GITHUB_OUTPUT
fi
check_token:
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
steps:

- name: "Checkout Lesson"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: "Set up R"
uses: r-lib/actions/setup-r@v2
Expand All @@ -93,17 +93,17 @@ jobs:
- name: Create Pull Request
id: cpr
if: ${{ steps.update.outputs.n > 0 }}
uses: peter-evans/create-pull-request@v3.10.0
uses: peter-evans/create-pull-request@v4.2.0
with:
token: ${{ secrets.SANDPAPER_WORKFLOW }}
delete-branch: true
branch: "update-${{ steps.update.outputs.n }}-packages-${{ steps.update.outputs.date }}"
branch: "update/packages"
commit-message: "[actions] update ${{ steps.update.outputs.n }} packages"
title: "Update ${{ steps.update.outputs.n }} packages"
body: |
:robot: This is an automated build
This will update the following package versions in your lesson:
This will update ${{ steps.update.outputs.n }} packages in your lesson with the following versions:
```
${{ steps.update.outputs.report }}
Expand All @@ -114,12 +114,12 @@ jobs:
If you want to inspect these changes locally, you can use the following code to check out a new branch:
```bash
git fetch origin update-${{ steps.update.outputs.n }}-packages-${{ steps.update.outputs.date }}
git checkout update-${{ steps.update.outputs.n }}-packages-${{ steps.update.outputs.date }}
git fetch origin update/packages
git checkout update/packages
```
- Auto-generated by [create-pull-request][1] via ${{ github.event.inputs.name }}
- Auto-generated by [create-pull-request][1] on ${{ steps.update.outputs.date }}
[1]: https://github.com/peter-evans/create-pull-request
labels: "type:package cache"
labels: "type: package cache"
draft: false
10 changes: 5 additions & 5 deletions .github/workflows/update-workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
if: ${{ needs.check_token.outputs.workflow == 'true' }}
steps:
- name: "Checkout Repository"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Update Workflows
id: update
Expand All @@ -47,20 +47,20 @@ jobs:
- name: Create Pull Request
id: cpr
if: "${{ steps.update.outputs.new }}"
uses: peter-evans/create-pull-request@v3.10.0
uses: peter-evans/create-pull-request@v4.2.0
with:
token: ${{ secrets.SANDPAPER_WORKFLOW }}
delete-branch: true
branch: "update-workflows-version-${{ steps.update.outputs.new }}"
branch: "update/workflows"
commit-message: "[actions] update sandpaper workflow to version ${{ steps.update.outputs.new }}"
title: "Update Workflows to Version ${{ steps.update.outputs.new }}"
body: |
:robot: This is an automated build
Update Workflows from sandpaper version ${{ steps.update.outputs.old }} -> ${{ steps.update.outputs.new }}
- Auto-generated by [create-pull-request][1] via ${{ github.event.inputs.name }}
- Auto-generated by [create-pull-request][1] on ${{ steps.update.outputs.date }}
[1]: https://github.com/peter-evans/create-pull-request
labels: "type:template and tools"
labels: "type: template and tools"
draft: false

0 comments on commit 0636f4c

Please sign in to comment.