Skip to content

Commit 9f707b1

Browse files
committed
GHA: Add update workflow
1 parent e3f337a commit 9f707b1

File tree

3 files changed

+81
-15
lines changed

3 files changed

+81
-15
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly

.github/workflows/update.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: update
2+
3+
permissions:
4+
contents: read
5+
6+
on: # yamllint disable-line rule:truthy
7+
workflow_dispatch:
8+
inputs:
9+
runid:
10+
description: 'GHA docs workflow run ID'
11+
required: true
12+
type: string
13+
push:
14+
description: 'Push update'
15+
default: false
16+
required: true
17+
type: boolean
18+
19+
jobs:
20+
21+
update:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
26+
steps:
27+
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Download documentation artifact
32+
run: >-
33+
gh run download
34+
--repo mpi4py/mpi4py
35+
--name mpi4py-docs
36+
${{ inputs.runid }}
37+
38+
- name: Update documentation contents
39+
run: |
40+
# unarchive
41+
docdir=mpi4py-docs
42+
unzip -q $docdir.zip
43+
mv $docdir/version .
44+
version=$(cat version)
45+
test ! -d $version
46+
mv $docdir $version
47+
rm -f stable
48+
ln -sf $version stable
49+
50+
- name: Commit changes
51+
run: |
52+
# git add + commit
53+
git config user.name "$(git log -1 --pretty=format:%an)"
54+
git config user.email "$(git log -1 --pretty=format:%ae)"
55+
version=$(cat version)
56+
git add $version stable
57+
git commit -m $version
58+
git show --stat
59+
60+
- name: Push changes
61+
if: ${{ inputs.push }}
62+
run: git push

update.sh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
#!/bin/bash
2-
set -eu
2+
set -euo pipefail
33

4-
version=$1
5-
workdir="$(pwd)"
6-
if test -d "$version"; then
7-
echo "version $version already exists!"
8-
exit 1
9-
fi
10-
tempdir="$(mktemp -d)"
11-
trap 'rm -rf $tempdir' EXIT
4+
error() { echo "error: $1"; exit 1; }
125

13-
cd "$tempdir"
14-
baseurl="https://github.com/mpi4py/mpi4py/releases/download"
15-
curl -sL "$baseurl/$version/mpi4py-$version.tar.gz" | tar xz
6+
test -n "${1-}" || error "expecting GHA workflow run ID"
7+
gh run download --repo mpi4py/mpi4py -n mpi4py-docs "$1"
8+
docdir="mpi4py-docs"
9+
rm -rf "$docdir"
10+
unzip -q "$docdir.zip"
1611

17-
cd "$workdir"
18-
mv "$tempdir/mpi4py-$version/docs" "$version"
19-
ln -sf "$version" "stable"
12+
version=$(cat "$docdir/version")
13+
test ! -d "$version" || error "$version already exists!"
14+
rm "$docdir/version"
15+
mv "$docdir" "$version"
2016

17+
rm -f "stable"
18+
ln -sf "$version" "stable"
2119
git add "$version" "stable"
2220
git commit -m "$version"

0 commit comments

Comments
 (0)