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: Workflow which detects what helm instance should be deployed | ||
on: | ||
workflow_call: | ||
outputs: | ||
cluster: | ||
description: "cluster type as dev, staging or prod" | ||
value: ${{ jobs.detect.outputs.dev }} | ||
instance: | ||
description: "Returns value of instance" | ||
value: ${{ jobs.detect.outputs.dev }} | ||
jobs: | ||
detect: | ||
name: Checking deployment conditions | ||
runs-on: ubuntu-latest | ||
env: | ||
COUNT: 0 | ||
outputs: | ||
instance: ${{ steps.split.outputs.instance }} | ||
steps: | ||
- id: clean | ||
name: Clean tag name | ||
env: | ||
REF_NAME: ${{ github.ref_name }} | ||
run: | | ||
echo "TAG=${REF_NAME##*/}" >> $GITHUB_ENV | ||
- id: instance | ||
name: Get instance | ||
run: | | ||
echo "INSTANCE=${TAG##*-}" >> $GITHUB_ENV | ||
- id: cluster | ||
name: Get cluster | ||
run: | | ||
echo "CLUSTER=${TAG%%-*}" >> $GITHUB_ENV | ||
- id: out | ||
name: Set ouptuts | ||
run: | | ||
echo "VALUES_FILE=${CLUSTER}/${INSTANCE}.yml" >> $GITHUB_ENV | ||
echo "cluster=${CLUSTER}" >> $GITHUB_OUTPUT | ||
echo "instance=${INSTANCE}" >> $GITHUB_OUTPUT | ||
- name: Print Outputs | ||
run: | | ||
echo ${{ steps.out.outputs.cluster }} | ||
echo ${{ steps.out.outputs.instance }} | ||
- id: no-instance | ||
if: env.INSTANCE == '' | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed(':heavy_exclamation_mark: We have no helm instances. Exiting pipeline with Fail status.') | ||
- id: no-cluster | ||
if: env.CLUSTER == '' | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed(':heavy_exclamation_mark: We have no cluster. Exiting pipeline with Fail status.') | ||
- id: no-cluster | ||
- id: no-values-file | ||
if: [-f env.VALUES_FILE] == false | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed(':heavy_exclamation_mark: We have no values file. Exiting pipeline with Fail status.') | ||
- id: check_files | ||
name: Check file existence | ||
uses: thebinaryfelix/check-file-existence-action@v1 | ||
with: | ||
files: env.VALUES_FILE | ||
- name: Files exist | ||
if: steps.check_files.outputs.exists == 'true' | ||
# Only runs if all of the files exist | ||
run: echo "All files exist!" |