Skip to content

CD

CD #25

Workflow file for this run

name: CD
on:
workflow_dispatch:
inputs:
TAG:
type: string
description: tag-to-deploy
jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
if [[ "${{ github.event.inputs.TAG }}" == *-dev ]]; then
echo 'matrix=["test"]' >> $GITHUB_OUTPUT
else
echo 'matrix=["test", "production"]' >> $GITHUB_OUTPUT
fi
deploy:
needs: setup-matrix
runs-on: ubuntu-latest
strategy:
matrix:
target_env: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }}
max-parallel: 1
environment: memelo-${{ matrix.target_env }}
steps:
- uses: actions/checkout@v5
- name: Run server setup
uses: dawidd6/action-ansible-playbook@v9
with:
requirements: requirements.yml
playbook: server_setup.yml
directory: ./
key: ${{ secrets.SSH_PRIVATE_KEY }}
vault_password: ${{ secrets.VAULT_PASSWORD }}
options: |
--inventory inventory/${{ matrix.target_env }}.yml
--limit ${{ matrix.target_env }}
- name: Deploy via Ansible
uses: dawidd6/action-ansible-playbook@v9
with:
requirements: requirements.yml
playbook: deploy.yml
directory: ./
key: ${{ secrets.SSH_PRIVATE_KEY }}
vault_password: ${{secrets.VAULT_PASSWORD}}
options: |
--inventory inventory/${{ matrix.target_env }}.yml
--limit ${{ matrix.target_env }}
--extra-vars release_version=${{ github.event.inputs.TAG }}
--extra-vars commit_hash=${{ github.event.inputs.TAG }}
--extra-vars repo_url=https://github.com/weoses/memelo.git
- name: Tests
uses: robherley/go-test-action@v0
with:
moduleDirectory: tests/e2e
env:
STORAGE_SERVICE_URI: ${{ secrets.TEST_STORAGE_SERVICE_URI }}
STORAGE_SERVICE_USERNAME: ${{ secrets.TEST_PROXY_USERNAME }}
STORAGE_SERVICE_PASSWORD: ${{ secrets.TEST_PROXY_PASSWORD }}
if: ${{ matrix.target_env == 'production' }}