-
Notifications
You must be signed in to change notification settings - Fork 14
59 lines (53 loc) · 1.93 KB
/
mike-redeploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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 "kuadrant@googlegroups.com"
- 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 }}