-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📦 BUILD: Force sync tags from frontend to readthedocs repo
- Loading branch information
1 parent
2cee466
commit ee97cfc
Showing
2 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
name: "sync-to-readthedocs-repo" | ||
permissions: | ||
contents: write | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
|
@@ -12,41 +11,69 @@ on: | |
- 'production/test/*' | ||
tags: | ||
- 'v*' | ||
- 'demo/*' | ||
|
||
jobs: | ||
extract_branch: | ||
extract_branch_or_tag: | ||
outputs: | ||
branch: ${{ steps.extractbranch.outputs.branch }} | ||
ref_name: ${{ steps.extract.outputs.ref_name }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: extractbranch | ||
name: Extract branch name | ||
- id: extract | ||
name: Extract branch or tag name | ||
shell: bash | ||
run: | | ||
echo "::set-output name=branch::${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | ||
echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | ||
echo "${{ steps.extractbranch.outputs.branch }}" | ||
REF_NAME="${GITHUB_REF#refs/*/}" | ||
echo "::set-output name=ref_name::$REF_NAME" | ||
echo "Extracted ref: $REF_NAME" | ||
build-and-deploy: | ||
needs: extract_branch | ||
permissions: | ||
contents: write | ||
needs: extract_branch_or_tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
# Conditional Checkout for Branch | ||
- name: Checkout Branch | ||
if: contains(github.ref, 'refs/heads/') | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- name: Create new branch if doesn't exist | ||
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.outputs.branch }} | ||
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.outputs.branch }} | ||
branch: ${{ needs.extract_branch_or_tag.outputs.ref_name }} | ||
force: true |