Skip to content

Commit

Permalink
Merge pull request #134 from stakater/version-update
Browse files Browse the repository at this point in the history
Fix head ref variable
  • Loading branch information
rasheedamir authored Nov 17, 2024
2 parents d7dfc7d + 4d6b520 commit bfc03cb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/pull_request_closed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ jobs:
persist-credentials: true
token: ${{ secrets.GH_TOKEN }}

- name: Store the current head ref as a url friendly variable
id: current_branch
env:
HEAD_REF: ${{ github.head_ref }}
run: |
url_friendly_branch=$(echo ${HEAD_REF} | sed -e 's/[]:@\/?&=#%+[\!$()*,;]/-/g')
echo "CURRENT_BRANCH=$(echo ${url_friendly_branch})" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -27,17 +35,24 @@ jobs:
- name: Install mike
run: pip3 install mike

- name: Run prepare_theme.sh script from repository to merge theme_common and theme_override folders
- name: Run prepare_theme_pr.sh script from repository to merge theme_common and theme_override folders
run: |
chmod +x prepare_theme.sh
./prepare_theme.sh
chmod +x prepare_theme_pr.sh
./prepare_theme_pr.sh
- name: Configure Git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "stakater-user"
- name: Delete redundant PR deployment
run: mike delete --push -b pull-request-deployments ${{ steps.current_branch.outputs.CURRENT_BRANCH }}

- name: Comment on PR
uses: mshick/add-pr-comment@v2
env:
HEAD_REF: ${{ github.head_ref }}
run: mike delete --push -b pull-request-deployments ${HEAD_REF//\//-}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message-success: "@${{ github.actor }} PR doc deploy was successfully deleted from branch pull-request-deployments"
message-failure: "@${{ github.actor }} PR doc deploy failed to be deleted on branch pull-request-deployments!"
allow-repeats: true
20 changes: 11 additions & 9 deletions .github/workflows/pull_request_versioned_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:
description: "GitHub token"
required: true

env:
# Store the current head ref as a url friendly variable
CURRENT_BRANCH: ${HEAD_REF//\//-}

jobs:
deploy_doc:
runs-on: ubuntu-latest
Expand All @@ -23,6 +19,14 @@ jobs:
persist-credentials: true
token: ${{ secrets.GH_TOKEN }}

- name: Store the current head ref as a url friendly variable
id: current_branch
env:
HEAD_REF: ${{ github.head_ref }}
run: |
url_friendly_branch=$(echo ${HEAD_REF} | sed -e 's/[]:@\/?&=#%+[\!$()*,;]/-/g')
echo "CURRENT_BRANCH=$(echo ${url_friendly_branch})" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -42,12 +46,10 @@ jobs:
git config --local user.name "stakater-user"
- name: Deploy PR docs
env:
HEAD_REF: ${{ github.head_ref }}
run: mike deploy --push -b pull-request-deployments $CURRENT_BRANCH
run: mike deploy --push -b pull-request-deployments ${{ steps.current_branch.outputs.CURRENT_BRANCH }}

- name: Update 'latest' alias to latest PR build
run: mike alias --push -b pull-request-deployments --update-aliases $CURRENT_BRANCH latest
run: mike alias --push -b pull-request-deployments --update-aliases ${{ steps.current_branch.outputs.CURRENT_BRANCH }} latest

- name: When publishing a new version, always update the alias to point to the latest version
run: mike set-default --push -b pull-request-deployments latest
Expand All @@ -57,6 +59,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message-success: "@${{ github.actor }} PR doc deploy will soon be available for review on https://stakater.github.io/mto-docs/${CURRENT_BRANCH}"
message-success: "@${{ github.actor }} PR doc deploy will soon be available for review on https://stakater.github.io/mto-docs/${{ steps.current_branch.outputs.CURRENT_BRANCH }}"
message-failure: "@${{ github.actor }} PR doc deploy failed!"
allow-repeats: true

0 comments on commit bfc03cb

Please sign in to comment.