Skip to content

Commit 9497354

Browse files
committed
Rewrite asset deploy.
This switches to `gh` which is the more modern CLI, and also available by default which removes the old installer script. This also tightens the scope where GITHUB_TOKEN is exposed to just the step where `gh` is executed. Finally, it tightens the permissions on the GITHUB_TOKEN (though `contents: write` is extremely permissive, since that allows writing to almost anything in the repo).
1 parent baa9364 commit 9497354

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ defaults:
77
run:
88
shell: bash
99

10+
permissions:
11+
contents: write
12+
1013
jobs:
1114
release:
1215
name: Deploy Release
@@ -32,14 +35,14 @@ jobs:
3235
os: windows-latest
3336
steps:
3437
- uses: actions/checkout@master
35-
- name: Install hub
36-
run: ci/install-hub.sh ${{ matrix.os }}
3738
- name: Install Rust
3839
run: ci/install-rust.sh stable ${{ matrix.target }}
39-
- name: Build and deploy artifacts
40+
- name: Build asset
41+
run: ci/make-release-asset.sh ${{ matrix.os }} ${{ matrix.target }}
42+
- name: Update release with new asset
4043
env:
4144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
run: ci/make-release-asset.sh ${{ matrix.os }} ${{ matrix.target }}
45+
run: gh release upload $MDBOOK_TAG $MDBOOK_ASSET
4346
pages:
4447
name: GitHub Pages
4548
runs-on: ubuntu-latest

ci/install-hub.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

ci/make-release-asset.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ case $1 in
4444
esac
4545
cd ../..
4646

47-
if [[ -z "$GITHUB_TOKEN" ]]
47+
if [[ -z "$GITHUB_ENV" ]]
4848
then
49-
echo "$GITHUB_TOKEN not set, skipping deploy."
49+
echo "GITHUB_ENV not set, run: gh release upload $TAG target/$asset"
5050
else
51-
hub release edit -m "" --attach $asset $TAG
51+
echo "MDBOOK_TAG=$TAG" >> $GITHUB_ENV
52+
echo "MDBOOK_ASSET=target/$asset" >> $GITHUB_ENV
5253
fi

0 commit comments

Comments
 (0)