2023-03-01 17:46:40 +01:00
|
|
|
name: Create staging infra (REUSABLE)
|
|
|
|
|
2023-03-02 11:56:14 +01:00
|
|
|
on:
|
2023-03-01 17:46:40 +01:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
TYPE:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
secrets:
|
|
|
|
CICD_SECRETS:
|
|
|
|
required: true
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
create:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
# Prepare
|
|
|
|
- name: Generate SSH keypair
|
|
|
|
run: ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N "" && ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub && echo -e "Host *\n StrictHostKeyChecking no" > ~/.ssh/ssh_config
|
|
|
|
if: inputs.TYPE != 'k8s'
|
|
|
|
- name: Checkout source code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install terraform
|
|
|
|
uses: hashicorp/setup-terraform@v2
|
|
|
|
- name: Install kubectl
|
|
|
|
uses: azure/setup-kubectl@v3
|
|
|
|
if: inputs.TYPE == 'k8s'
|
|
|
|
- name: Set up Python 3.11
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
if: inputs.TYPE != 'k8s'
|
|
|
|
with:
|
2023-03-09 10:04:59 +01:00
|
|
|
python-version: "3.11"
|
|
|
|
cache: "pip"
|
2023-03-01 17:46:40 +01:00
|
|
|
- name: Install ansible
|
|
|
|
run: pip install ansible
|
|
|
|
if: inputs.TYPE != 'k8s'
|
|
|
|
- name: Install ansible libs
|
2023-08-21 18:15:09 +02:00
|
|
|
run: ansible-galaxy install --timeout 120 monolithprojects.github_actions_runner,1.18.1 && ansible-galaxy collection install --timeout 120 community.general
|
2023-03-01 17:46:40 +01:00
|
|
|
if: inputs.TYPE != 'k8s'
|
|
|
|
# Create infra
|
|
|
|
- run: ./tests/create.sh ${{ inputs.TYPE }}
|
|
|
|
env:
|
|
|
|
CICD_SECRETS: ${{ secrets.CICD_SECRETS }}
|
|
|
|
- run: tar -cvf terraform.tar /tmp/${{ inputs.TYPE }}
|
|
|
|
if: always()
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
name: tf-${{ inputs.TYPE }}
|
|
|
|
path: terraform.tar
|