Skip to content

Creating sdf by @gurevichdmitry #37

Creating sdf by @gurevichdmitry

Creating sdf by @gurevichdmitry #37

Workflow file for this run

name: Test Upgrade Environment
run-name: Creating ${{ github.event.inputs.deployment_name }} by @${{ github.actor }}
on:
# Ability to execute on demand
workflow_dispatch:
inputs:
deployment_name:
type: string
description: |
Name with letters, numbers, hyphens; start with a letter. Max 20 chars. e.g., 'my-env-123'
required: true
elk-stack-version:
required: true
description: "Stack version: For released/BC version use 8.x.y, for SNAPSHOT use 8.x.y-SNAPSHOT"
default: "8.11.0"
docker-image-override:
required: false
description: "Provide the full Docker image path to override the default image (e.g. for testing BC/SNAPSHOT)"
new-param:
type: string
description: "Hey"
env:
VERSION: 'docker.elastic.co/beats/elastic-agent:${{ inputs.elk-stack-version}}'
DOCKER_IMAGE: ${{ inputs.docker-image-override }}
jobs:
init:
runs-on: ubuntu-20.04
outputs:
stack-version: ${{ steps.set-previous-version.outputs.PREVIOUS_VERSION }}
new-param: ${{ steps.data.outputs.new-param }}
steps:
- name: Pass data
id: data
env:
SECRET: ${{ secrets.GPG_PASSPRHASE }}
run: |
new_param=$(jq -r '.inputs["new-param"]' $GITHUB_EVENT_PATH)
echo "::add-mask::$new_param"
new_param_encrypted=$(gpg --symmetric --batch --passphrase "$SECRET" --output - <(echo "$new_param") | base64 -w0)
echo "new-param=$new_param_encrypted" >> $GITHUB_OUTPUT
- name: Update Image
if: ${{ ! inputs.docker-image-override }}
run: |
echo "DOCKER_IMAGE=${{ env.VERSION }}" >> $GITHUB_ENV
- name: Print Docker image
run: |
echo $DOCKER_IMAGE
- name: Set Previous Version
id: set-previous-version
run: |
VERSION="${{ inputs.elk-stack-version }}"
# Extract the major and minor versions
MAJOR_VERSION=$(echo $VERSION | cut -d'.' -f1)
MINOR_VERSION=$(echo $VERSION | cut -d'.' -f2)
# Calculate the previous version (assuming it's always X.(Y-1))
PREVIOUS_VERSION="$MAJOR_VERSION.$((MINOR_VERSION - 1))"
echo $PREVIOUS_VERSION
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
- name: Print previous version
id: prev-version
run: echo "${{ steps.set-previous-version.outputs.PREVIOUS_VERSION }}"
check-init:
runs-on: ubuntu-20.04
needs: init
env:
SECRET: ${{ secrets.GPG_PASSPRHASE }}
steps:
- name: Print prev version in job
run: |
echo "${{needs.init.outputs.stack-version}}"
new_param_decrypted=$(gpg --decrypt --quiet --batch --passphrase "$SECRET" --output - <(echo "${{ needs.init.outputs.new-param }}" | base64 --decode))
echo "::add-mask::$new_param_decrypted"
echo "NEW_PARAM=$new_param_decrypted" >> $GITHUB_ENV
- name: Test env var
env:
MY_VAL: ${{ env.NEW_PARAM }}
run: echo "$MY_VAL"
# deploy:
# uses: ./.github/workflows/test-job.yml
# needs: init
# with:
# deployment_name: ${{ github.event.inputs.deployment_name }}
# ec-api-key: "sdfsdf"
# ec-stack-version: "${{needs.init.outputs.stack-version}}"
# upgrade:
# runs-on: ubuntu-20.04
# needs: deploy
# steps:
# - id: set-vars
# run: echo ${{ needs.deploy.outputs.ec-key }} ${{ needs.deploy.outputs.public-key }}