Creating dep by @gurevichdmitry #35
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: 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 | |
run: | | |
new_param=$(jq -r '.inputs["new-param"]' $GITHUB_EVENT_PATH) | |
echo "::add-mask::$new_param" | |
echo "new-param=$new_param" >> $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 | |
steps: | |
- name: Print prev version in job | |
run: | | |
echo "${{needs.init.outputs.stack-version}}" | |
echo "${{needs.init.outputs.new-param}}" | |
# 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 }} |