Re-deploy via mike #27
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: Re-deploy via mike | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'The version to deploy' | |
required: true | |
default: '0.8.0' | |
sourceBranch: | |
description: 'Source Branch' | |
required: true | |
default: '0.8' | |
jobs: | |
mike-redeploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetches all history for all branches and tags | |
ref: ${{ github.event.inputs.sourceBranch }} | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install Requirements | |
run: pip install -r requirements.txt | |
- name: Validate User Permissions | |
id: validate_user | |
run: | | |
USER_PERMISSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission") | |
echo "User permissions: $USER_PERMISSION" | |
if [[ "$USER_PERMISSION" =~ (\"permission\": \"admin\") ]]; then | |
echo "User is authorized to deploy." | |
echo "::set-output name=can_deploy::true" | |
else | |
echo "::error::User is not authorized to deploy." | |
echo "::set-output name=can_deploy::false" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Git Config | |
if: steps.validate_user.outputs.can_deploy == 'true' | |
run: | | |
git config --global user.name "Docs Deploy" | |
git config --global user.email "[email protected]" | |
- name: Deploy Documentation | |
if: steps.validate_user.outputs.can_deploy == 'true' | |
run: | | |
mike deploy ${{ github.event.inputs.version }} -t "${{ github.event.inputs.version }}" --push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |