Skip to content

Commit 4356a46

Browse files
author
Andrea Luzzardi
authored
docs: publish only on release (#213)
Signed-off-by: Andrea Luzzardi <al@dagger.io>
1 parent 6f25210 commit 4356a46

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/publish-docs.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish Docs
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
source:
9+
description: "Tag or branch to publish to docs branch"
10+
required: true
11+
12+
jobs:
13+
publish-docs:
14+
name: Publish Docs
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Publish to docs branch
25+
run: |
26+
git config user.name "github-actions[bot]"
27+
git config user.email "github-actions[bot]@users.noreply.github.com"
28+
29+
if [ "${{ github.event_name }}" = "release" ]; then
30+
SOURCE="${GITHUB_REF#refs/tags/}"
31+
else
32+
SOURCE="${{ github.event.inputs.source }}"
33+
fi
34+
35+
SOURCE_SHA=$(git rev-parse $SOURCE)
36+
git push -f https://github-actions[bot]:${{ secrets.RELEASE_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git "$SOURCE_SHA:refs/heads/docs"
37+
env:
38+
RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}

0 commit comments

Comments
 (0)