-
Notifications
You must be signed in to change notification settings - Fork 44
79 lines (72 loc) · 2.29 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: "sync-to-readthedocs-repo"
on:
workflow_dispatch:
push:
branches:
- main
- latest
- develop
- 'pre/*'
- 'production/test/*'
tags:
- 'v*'
- 'demo/*'
jobs:
extract_branch_or_tag:
outputs:
ref_name: ${{ steps.extract.outputs.ref_name }}
runs-on: ubuntu-latest
steps:
- id: extract
name: Extract branch or tag name
shell: bash
run: |
REF_NAME="${GITHUB_REF#refs/*/}"
echo "::set-output name=ref_name::$REF_NAME"
echo "Extracted ref: $REF_NAME"
build-and-deploy:
permissions:
contents: write
needs: extract_branch_or_tag
runs-on: ubuntu-latest
steps:
# Conditional Checkout for Branch
- name: Checkout Branch
if: contains(github.ref, 'refs/heads/')
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.GH_PAT }}
ref: ${{ needs.extract_branch_or_tag.outputs.ref_name }}
# Conditional Checkout for Tag
- name: Checkout Tag
if: contains(github.ref, 'refs/tags/')
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.GH_PAT }}
fetch-depth: 0
ref: ${{ needs.extract_branch_or_tag.outputs.ref_name }}
fetch-tags: true
- name: Create new branch or tag
uses: GuillaumeFalourd/[email protected]
if: contains(github.ref, 'refs/heads/')
with:
repository_owner: flexcompute-readthedocs
repository_name: tidy3d-docs
new_branch_name: ${{ needs.extract_branch_or_tag.outputs.ref_name }}
access_token: ${{ secrets.GH_PAT }}
new_branch_ref: default_clean_sync_branch
ignore_branch_exists: true
- name: Tag and push
if: contains(github.ref, 'refs/tags/')
run: |
git push --force --tags https://${{ secrets.GH_PAT }}@github.com/flexcompute-readthedocs/tidy3d-docs.git
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: .
token: ${{ secrets.GH_PAT }}
repository-name: flexcompute-readthedocs/tidy3d-docs
target-folder: .
branch: ${{ needs.extract_branch_or_tag.outputs.ref_name }}
force: true