-
Notifications
You must be signed in to change notification settings - Fork 44
63 lines (63 loc) · 1.84 KB
/
sync-to-readthedocs-repo.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: sync-to-readthedocs-repo
permissions:
contents: write
on:
push:
branches:
- main
- latest
- repo_merge_no_history
workflow_dispatch:
inputs:
env:
description: environment
default: dev
required: true
jobs:
set_env:
outputs:
env: ${{ steps.setenv.outputs.env }}
dest-branch: ${{ steps.dest-branch.outputs.branch }}
runs-on: ubuntu-latest
steps:
- id: setenv
run: |
if test -n "${{ github.event.inputs.env }}"
then
echo "::set-output name=env::${{ github.event.inputs.env }}"
echo "ENV=${{ github.event.inputs.env }}" >> $GITHUB_ENV
elif test "${{ github.event_name }}" = 'push' -a "${{ github.ref }}" = 'refs/heads/latest'
then
echo "::set-output name=env::dev"
echo "ENV=dev" >> $GITHUB_ENV
elif test "${{ github.event_name }}" = 'push' -a "${{ github.ref }}" = 'refs/heads/main'
then
echo "::set-output name=env::prod"
echo "ENV=prod" >> $GITHUB_ENV
else
echo "::set-output name=env::dev"
echo "ENV=dev" >> $GITHUB_ENV
fi
- id: dest-branch
run: |
case ${{ env.ENV }} in
dev)
echo "::set-output name=branch::repo_merge_no_history"
;;
prod)
echo "::set-output name=branch::main"
;;
esac
build-and-deploy:
needs: set_env
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: .
token: ${{ secrets.GH_PAT }}
repository-name: flexcompute-readthedocs/tidy3d-docs-demo
target-folder: .
branch: ${{ needs.set_env.outputs.dest-branch }}