Manual Env Deploy #355
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: Manual Env Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
destination_branch: | |
type: choice | |
description: 'Destination environment' | |
required: true | |
default: 'stage' | |
options: ['stage', 'main'] | |
jobs: | |
stage-merge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if user is allowed to execute the workflow | |
run: | | |
if [[ "${{ github.event_name }}" == 'workflow_dispatch' && ("${{ github.actor }}" != 'coretex-admin' && "${{ github.actor }}" != 'igorperic17' && "${{ github.repository_owner }}" != "${{ github.actor }}" ) ]]; then | |
echo "::error::You are not authorized to execute this workflow." | |
exit 1 | |
fi | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Merge develop into destination branch | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git fetch | |
git checkout stage | |
git pull | |
git pull --rebase origin develop | |
git push --force | |
prod-merge: | |
needs: stage-merge | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.destination_branch == 'main' }} | |
steps: | |
- name: Check if user is allowed to execute the workflow | |
run: | | |
allowed_users=("igorperic17" "coretex-admin") | |
if [[ "${{ github.event_name }}" == 'workflow_dispatch' && ! ("${{ github.repository_owner }}" == "${{ github.actor }}" || "${allowed_users[*]}" =~ "${{ github.actor }}" ) ]]; then | |
echo "::error::You are not authorized to execute this workflow." | |
exit 1 | |
fi | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Merge develop into destination branch | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git fetch | |
git checkout main | |
git pull | |
git pull --rebase origin stage | |
git push --force |