Update Env #204
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: Update Env | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment' | |
required: true | |
default: 'prod' | |
type: choice | |
options: | |
- stage | |
- prod | |
action: | |
description: 'Desired action against env' | |
required: true | |
default: 'update' | |
type: choice | |
options: | |
- update | |
- revert | |
desired_sha: | |
description: '[Optional] Target Short SHA' | |
required: false | |
default: '' | |
type: string | |
deployment_description: | |
description: 'A brief description of what changed in this deployment' | |
required: false | |
default: 'Production Update/Revert via Github Action' | |
type: string | |
jobs: | |
config: | |
name: Config | |
runs-on: ubuntu-latest | |
outputs: | |
get-server-ip-list: ${{ steps.get-server-ip-list.outputs.get-server-ip-list }} | |
steps: | |
- id: get-server-ip-list | |
name: Get Server IP List | |
run: echo "get-server-ip-list=$(dig +short app-servers.thinky.gg TXT | jq -cr 'split(",")')" >> $GITHUB_OUTPUT | |
- name: print output | |
run: | | |
echo "${{ steps.get-server-ip-list.outputs.get-server-ip-list }}" | |
deploy-new-containers: | |
name: Update Production | |
runs-on: ubuntu-latest | |
needs: | |
- config | |
strategy: | |
matrix: | |
server: ${{ fromJson(needs.config.outputs.get-server-ip-list) }} | |
steps: | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_KEY" > ~/.ssh/pathology | |
chmod 600 ~/.ssh/pathology | |
cat >>~/.ssh/config <<END | |
Host * | |
User $SSH_USER | |
IdentityFile ~/.ssh/pathology | |
StrictHostKeyChecking no | |
END | |
env: | |
SSH_USER: ${{ secrets.SERVER_SSH_USER }} | |
SSH_KEY: ${{ secrets.SERVER_SSH_KEY }} | |
- name: Update Environments with New Containers - Default | |
if: github.event.inputs.desired_sha == '' | |
run: ssh ${{ matrix.server }} 'bash /opt/pathology/scripts/update-Environments.sh -e ${{ inputs.environment }} -a ${{ inputs.action }} -c "${{ inputs.deployment_description }}"' | |
- name: Update Environments with New Containers - With SHA | |
if: github.event.inputs.desired_sha != '' | |
run: ssh ${{ matrix.server }} 'bash /opt/pathology/scripts/update-Environments.sh -e ${{ inputs.environment }} -a ${{ inputs.action }} -c "${{ inputs.deployment_description }}" -v "${{ inputs.desired_sha }}"' |