chore: initial commit #1
Workflow file for this run
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
name: Deploy | |
on: | |
push: | |
tags: | |
- v[0-9]+.[0-9]+.[0-9]+ | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: mkdocs | |
steps: | |
- name: Checkout to the branch of the tag | |
run: | | |
# checkout from GitHub CI without using actions/checkout | |
git clone https://oauth2:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git . | |
git fetch origin ${{ github.ref_name }} | |
# check if git tag is the last commit of some branch | |
TAG=${{ github.ref_name }} | |
git branch -a --contains $TAG | |
BRANCH=$(git branch -a --contains $TAG | grep -v HEAD | head -n 1 | sed 's/^* //' | sed 's/^ //') | |
echo "branch: $BRANCH" | |
LAST_COMMIT=$(git rev-parse $BRANCH) | |
echo "last commit hash: $LAST_COMMIT" | |
TAG_COMMIT=$(git rev-list -n 1 $TAG) | |
echo "tag commit hash: $TAG_COMMIT" | |
if [[ "$LAST_COMMIT" != "$TAG_COMMIT" ]]; then | |
echo "ERROR: Tag $TAG is NOT the last commit of branch $BRANCH. Exiting.." | |
exit 1 | |
fi | |
git checkout "$BRANCH" | |
- name: Update CHANGELOG | |
id: changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
includeInvalidCommits: true | |
excludeTypes: build,docs,style | |
token: ${{ github.token }} | |
tag: ${{ github.ref_name }} | |
- name: Commit CHANGELOG.md | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git tag -d ${{ github.ref_name }} | |
git push origin --delete ${{ github.ref_name }} | |
git add CHANGELOG.md | |
git commit -m "docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]" | |
git tag -a ${{ github.ref_name }} -m ${{ github.ref_name }} | |
git push | |
git push --tags | |
- name: Create Release | |
uses: ncipollo/release-action@v1.12.0 | |
with: | |
allowUpdates: true | |
draft: false | |
makeLatest: true | |
name: ${{ github.ref_name }} | |
body: ${{ steps.changelog.outputs.changes }} | |
token: ${{ github.token }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip3 install -r requirements_docs.txt | |
- name: Run mkdocs | |
run: | | |
set +e # Do not exit shell on failure | |
export GL_PROJECT=kiyoon/python-project-template-docs | |
export HTTPS_REMOTE="https://gitlab-ci-token:${{ secrets.GL_TOKEN }}@gitlab.com/$GL_PROJECT.git" | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git remote add gitlab "$HTTPS_REMOTE" | |
git branch -D gl-pages | |
git pull gitlab gl-pages:gl-pages | |
# Delete the latest page because we're going to make it as an alias to the latest version. | |
mike delete --deploy-prefix public -r $HTTPS_REMOTE -b gl-pages latest | |
out=$(mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b gl-pages -u ${{ github.ref_name }} latest 2> stderr.txt) | |
exit_code=$? | |
err=$(<stderr.txt) | |
mike set-default --deploy-prefix public -r $HTTPS_REMOTE -p -b gl-pages latest | |
# Display the raw output in the step | |
echo "${out}" | |
echo "${err}" | |
# Display the Markdown output in the job summary | |
echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY | |
echo "${out}" >> $GITHUB_STEP_SUMMARY | |
echo "${err}" >> $GITHUB_STEP_SUMMARY | |
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
exit ${exit_code} |