Skip to content

Commit

Permalink
ci: 🎡 use gh-pages branch for deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
abcfy2 committed Jun 12, 2023
1 parent 4aaec64 commit 6989de1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tn-p1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ jobs:
name: test-report
path: reports/

- uses: actions/upload-pages-artifact@v1
- uses: actions/upload-artifact@v3
if: github.event_name == 'push'
with:
name: token-negotiator-dist
path: token-negotiator-dist/

- name: "Setup registry"
Expand Down
43 changes: 38 additions & 5 deletions .github/workflows/tn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:
- main
- staging
- ci-testing
tags:
- "v*"
pull_request:
branches:
- "*"
workflow_dispatch:

jobs:
tn-p1:
Expand Down Expand Up @@ -40,12 +43,42 @@ jobs:
permissions:
pages: write
id-token: write
environment:
name: gh-pages
url: ${{ steps.deployment.outputs.page_url }}
contents: write
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(fromJson('["main", "ci-testing"]'), github.ref_name)
if: github.event_name == 'push' && (contains(fromJson('["main", "ci-testing"]'), github.ref_name) || github.ref_type == 'tag' )
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: token-negotiator-dist
path: token-negotiator-dist/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git config --global credential.helper store
echo "https://oauth2:${GITHUB_TOKEN}@github.com" > ~/.git-credentials
TARGET=latest
if [ x"${GITHUB_REF_TYPE}" = x"tag" ]; then
TARGET="${GITHUB_REF_NAME}"
fi
npx -y @koumoul/gh-pages-multi deploy -s token-negotiator-dist/ -t "${TARGET}" --no-history -v
- name: copy latest dir to root dir
run: |
git remote set-branches origin 'gh-pages'
git fetch origin gh-pages
git checkout .
git checkout gh-pages
rm -fr token-negotiator-dist
if [ -d "latest" ]; then
rm -fr theme negotiator*
cp -frv latest/. .
fi
git add .
if ! git diff --quiet HEAD; then
git commit -a --amend --no-edit
git push -f
fi

0 comments on commit 6989de1

Please sign in to comment.