cargo/.github/workflows/contrib.yml
bors f806be2dde Auto merge of #12835 - dvdhrm:pr/contrib-concurrency, r=weihanglo
ci/contrib: use separate concurrency group

Run the contrib workflow in its own concurrency group to avoid multiple runs causing conflicting git pushes.

The contrib workflow pushes to the gh-pages branch, and thus is not safe to be run multiple times in parallel. Given that github-actions can stall workflow runs for quite some time, multiple executions can overtake each other. By using concurrency groups, all workflow runs will wait until previous runs completed.

Given that the workflow uses orphan-branches and forced pushes, conflicting workflows will not fail, but might produce outdated data if they overtake each other.

We explicitly disable cancellation to get better diagnostics and more easily find the first possible run that failed. Since these workflow runs are rather fast, and only run on master, cancellation seems not necessary.
2023-10-17 19:04:23 +00:00

40 lines
1 KiB
YAML

name: Contrib Deploy
on:
push:
branches:
- master
concurrency:
cancel-in-progress: false
group: "gh-pages"
permissions:
contents: read
jobs:
deploy:
permissions:
contents: write # for Git to git push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install mdbook
run: |
mkdir mdbook
curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.27/mdbook-v0.4.27-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Deploy docs
run: |
cd src/doc/contrib
mdbook build
# Override previous ref to avoid keeping history.
git worktree add --orphan -B gh-pages gh-pages
git config user.name "Deploy from CI"
git config user.email ""
cd gh-pages
mv ../book contrib
git add contrib
git commit -m "Deploy $GITHUB_SHA to gh-pages"
git push origin +gh-pages