Deploy on dev #23
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: Deploy on dev | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'App version to deploy' | |
required: true | |
default: '1.0.0' | |
env: | |
ENVIRONMENT: dev | |
REGION: eu-central-1 | |
TEAM: Platform-Engineering | |
jobs: | |
release: | |
name: Deploy workoutrecorder-backend | |
runs-on: [self-hosted, dev] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Pull SSH key for Ansible connection | |
run: | | |
cd ansible | |
aws s3 cp \ | |
s3://red-devops-workout-recorder/post-provisioning/app_${{ env.ENVIRONMENT }}_key.pem \ | |
app_${{ env.ENVIRONMENT }}_key.pem | |
chmod 600 app_${{ env.ENVIRONMENT }}_key.pem | |
- name: Download artifact | |
run: | | |
cd ansible | |
aws s3 cp \ | |
s3://red-devops-workout-recorder/release/workoutrecorder-backend-${{ github.event.inputs.version }}.jar \ | |
workoutrecorder-backend-${{ github.event.inputs.version }}.jar | |
- name: Ansible Playbook | |
run: | | |
cd ansible | |
ansible-playbook \ | |
deploy.yaml \ | |
-i ./inventories/${{ env.ENVIRONMENT }}/inventory_aws_ec2.yaml \ | |
-extra-vars="app_version=${{ github.event.inputs.version }}" \ | |
--private-key app_${{ env.ENVIRONMENT }}_key.pem | |
- name: Remove SSH key | |
if: always() | |
run: | | |
cd ansible | |
rm app_${{ env.ENVIRONMENT }}_key.pem -f | |
continue-on-error: true |