Skip to content

Commit

Permalink
NR-164383 provision canaries with Terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenruizdegauna committed Jan 31, 2024
1 parent 18895bd commit dd04892
Show file tree
Hide file tree
Showing 15 changed files with 417 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/canaries_prune.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
- linux
- windows
required: false
tag:
description: 'Tag to prune'
required: true

permissions:
id-token: write
Expand All @@ -22,5 +25,6 @@ jobs:
uses: ./.github/workflows/component_canaries_prune.yml
with:
PLATFORM: ${{ github.event.inputs.platform }}
TAG: ${{ github.event.inputs.tag }}
secrets:
AWS_VPC_SUBNET: ${{secrets.AWS_VPC_SUBNET}}
161 changes: 160 additions & 1 deletion .github/workflows/component_canaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ permissions:
id-token: write

jobs:
canaries:
canaries_macos:
runs-on: ubuntu-20.04
if: ${{ inputs.PLATFORM == 'macos' }}
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -59,3 +60,161 @@ jobs:
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"

canaries_linux:
runs-on: ubuntu-20.04
if: ${{ inputs.PLATFORM == 'linux' }}
steps:
- uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
aws-region: us-east-2

- name: Set branch name
run: |
# Short name for current branch. For PRs, use target branch (base ref)
GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
# Is the ref a tag? If so, remove refs/tags/ prefix
GIT_BRANCH=${GIT_BRANCH#refs/tags/}
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
- name: Add to env current and previous versions
run: .github/workflows/scripts/set_version.sh ${{ inputs.TAG }}

- name: set vars for legibility (state, inventory ...)
run: |
echo "PREVIOUS_TERRAFORM_STATE=canaries-${{ inputs.PLATFORM }}-${{ env.PREVIOUS_NR_VERSION }}" >> $GITHUB_ENV
echo "TERRAFORM_STATE=canaries-${{ inputs.PLATFORM }}-${{ inputs.TAG }}" >> $GITHUB_ENV
echo "INVENTORY_OUTPUT=/srv/runner/inventory/canary-${{ inputs.TAG }}-${{ inputs.PLATFORM }}-inventory.ec2" >> $GITHUB_ENV
- name: Provision instances ${{ inputs.PLATFORM }}
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "test/provision TERRAFORM_STATE_KEY=${{ env.TERRAFORM_STATE }} PREFIX=canary INVENTORY_OUTPUT=${{ env.INVENTORY_OUTPUT }} TAG_OR_UNIQUE_NAME=${{ inputs.TAG }} PLATFORM=${{ inputs.PLATFORM }} CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"
log_filters: |
\[ALLOW_MSG\].+
TASK\s\[.*\]\s
PLAY\s\[.*\]\s
PLAY\sRECAP\s
Apply\scomplete!
ok=\d+\s+changed=\d+\s+unreachable=\d+\s+failed=\d+\s+skipped=\d+\s+rescued=\d+\s+ignored=\d+
- name: Install Infra Agent
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "terraform-canaries ANSIBLE_INVENTORY=${{ env.INVENTORY_OUTPUT }} PLATFORM=${{ inputs.PLATFORM }} ANSIBLE_FORKS=${{ env.ANSIBLE_FORKS }} VERSION=${{ env.NR_VERSION }} PREVIOUS_VERSION=${{ env.PREVIOUS_NR_VERSION }} CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"

canaries_windows:
runs-on: ubuntu-20.04
if: ${{ inputs.PLATFORM == 'windows' }}
steps:
- uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
aws-region: us-east-2

- name: Set branch name
run: |
# Short name for current branch. For PRs, use target branch (base ref)
GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
# Is the ref a tag? If so, remove refs/tags/ prefix
GIT_BRANCH=${GIT_BRANCH#refs/tags/}
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
- name: Add to env current and previous versions
run: .github/workflows/scripts/set_version.sh ${{ inputs.TAG }}

- name: set vars for legibility (state, inventory ...)
run: |
echo "TERRAFORM_STATE_PREVIOUS=canaries-${{ inputs.PLATFORM }}-${{ inputs.TAG }}-previous" >> $GITHUB_ENV
echo "TERRAFORM_STATE_CURRENT=canaries-${{ inputs.PLATFORM }}-${{ inputs.TAG }}-current" >> $GITHUB_ENV
echo "INVENTORY_PREVIOUS=/srv/runner/inventory/canary-${{ inputs.TAG }}-${{ inputs.PLATFORM }}-previous-inventory.ec2" >> $GITHUB_ENV
echo "INVENTORY_CURRENT=/srv/runner/inventory/canary-${{ inputs.TAG }}-${{ inputs.PLATFORM }}-current-inventory.ec2" >> $GITHUB_ENV
- name: Provision instances ${{ inputs.PLATFORM }} previous
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "test/provision TERRAFORM_STATE_KEY=${{ env.TERRAFORM_STATE_PREVIOUS }} PREFIX=canary INVENTORY_OUTPUT=${{ env.INVENTORY_PREVIOUS }} TAG_OR_UNIQUE_NAME=${{ env.PREVIOUS_NR_VERSION }} PLATFORM=${{ inputs.PLATFORM }} CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"
log_filters: |
\[ALLOW_MSG\].+
TASK\s\[.*\]\s
PLAY\s\[.*\]\s
PLAY\sRECAP\s
Apply\scomplete!
ok=\d+\s+changed=\d+\s+unreachable=\d+\s+failed=\d+\s+skipped=\d+\s+rescued=\d+\s+ignored=\d+
- name: Provision instances ${{ inputs.PLATFORM }} current
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "test/provision TERRAFORM_STATE_KEY=${{ env.TERRAFORM_STATE_CURRENT }} PREFIX=canary INVENTORY_OUTPUT=${{ env.INVENTORY_CURRENT }} TAG_OR_UNIQUE_NAME=${{ env.NR_VERSION }} PLATFORM=${{ inputs.PLATFORM }} CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"
log_filters: |
\[ALLOW_MSG\].+
TASK\s\[.*\]\s
PLAY\s\[.*\]\s
PLAY\sRECAP\s
Apply\scomplete!
ok=\d+\s+changed=\d+\s+unreachable=\d+\s+failed=\d+\s+skipped=\d+\s+rescued=\d+\s+ignored=\d+
- name: Install Infra Agent previous
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "terraform-canaries ANSIBLE_INVENTORY=${{ env.INVENTORY_PREVIOUS }} PLATFORM=${{ inputs.PLATFORM }} ANSIBLE_FORKS=${{ env.ANSIBLE_FORKS }} VERSION=${{ env.PREVIOUS_NR_VERSION }} PREVIOUS_VERSION='NOT_USED_VALUE' CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"

- name: Install Infra Agent current
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "terraform-canaries ANSIBLE_INVENTORY=${{ env.INVENTORY_CURRENT }} PLATFORM=${{ inputs.PLATFORM }} ANSIBLE_FORKS=${{ env.ANSIBLE_FORKS }} VERSION=${{ env.NR_VERSION }} PREVIOUS_VERSION='NOT_USED_VALUE' CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"
88 changes: 84 additions & 4 deletions .github/workflows/component_canaries_prune.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
required: true

inputs:
TAG:
required: true
type: string
PLATFORM:
required: true
type: string
Expand All @@ -19,8 +22,9 @@ permissions:
id-token: write

jobs:
canaries-prune:
if: ${{ always() }}

canaries-prune-linux:
if: ${{ inputs.PLATFORM == 'linux' || inputs.PLATFORM == '' }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand All @@ -39,15 +43,91 @@ jobs:
GIT_BRANCH=${GIT_BRANCH#refs/tags/}
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
- name: Prune old canaries
- name: set vars for legibility (state, inventory ...)
run: |
echo "TERRAFORM_STATE=canaries-linux-${{ inputs.TAG }}" >> $GITHUB_ENV
- name: Clean previous canaries instances Linux
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "test/provision/clean TERRAFORM_STATE_KEY=${{ env.TERRAFORM_STATE }} PREFIX=canary INVENTORY_OUTPUT=NOT_USED TAG_OR_UNIQUE_NAME=${{ inputs.TAG }} PLATFORM=linux CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"
log_filters: |
\[ALLOW_MSG\].+
TASK\s\[.*\]\s
PLAY\s\[.*\]\s
PLAY\sRECAP\s
Apply\scomplete!
ok=\d+\s+changed=\d+\s+unreachable=\d+\s+failed=\d+\s+skipped=\d+\s+rescued=\d+\s+ignored=\d+
canaries-prune-windows:
if: ${{ inputs.PLATFORM == 'windows' || inputs.PLATFORM == '' }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
aws-region: us-east-2

- name: Set branch name
run: |
# Short name for current branch. For PRs, use target branch (base ref)
GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
# Is the ref a tag? If so, remove refs/tags/ prefix
GIT_BRANCH=${GIT_BRANCH#refs/tags/}
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
- name: set vars for legibility (state, inventory ...)
run: |
echo "PREVIOUS_TERRAFORM_STATE=canaries-windows-${{ inputs.TAG }}-previous" >> $GITHUB_ENV
echo "TERRAFORM_STATE=canaries-windows-${{ inputs.TAG }}-current" >> $GITHUB_ENV
- name: Clean previous canaries instances Windows (previous)
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "test/provision/clean TERRAFORM_STATE_KEY=${{ env.PREVIOUS_TERRAFORM_STATE }} PREFIX=canary INVENTORY_OUTPUT=NOT_USED TAG_OR_UNIQUE_NAME=${{ inputs.TAG }} PLATFORM=windows CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"
log_filters: |
\[ALLOW_MSG\].+
TASK\s\[.*\]\s
PLAY\s\[.*\]\s
PLAY\sRECAP\s
Apply\scomplete!
ok=\d+\s+changed=\d+\s+unreachable=\d+\s+failed=\d+\s+skipped=\d+\s+rescued=\d+\s+ignored=\d+
- name: Clean previous canaries instances Windows (current)
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "canaries-prune-auto PLATFORM=${{ inputs.PLATFORM }}"
container_make_target: "test/provision/clean TERRAFORM_STATE_KEY=${{ env.TERRAFORM_STATE }} PREFIX=canary INVENTORY_OUTPUT=NOT_USED TAG_OR_UNIQUE_NAME=${{ inputs.TAG }} PLATFORM=windows CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
cloud_watch_logs_stream_name: ecs/test-prerelease
aws_vpc_subnet: ${{ secrets.AWS_VPC_SUBNET }}
repo_name: "newrelic/infrastructure-agent"
ref: "${{ env.GIT_BRANCH }}"
log_filters: |
\[ALLOW_MSG\].+
TASK\s\[.*\]\s
PLAY\s\[.*\]\s
PLAY\sRECAP\s
Apply\scomplete!
ok=\d+\s+changed=\d+\s+unreachable=\d+\s+failed=\d+\s+skipped=\d+\s+rescued=\d+\s+ignored=\d+
6 changes: 3 additions & 3 deletions .github/workflows/component_prerelease_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "test/provision PREFIX=pkg-tests INVENTORY_OUTPUT=/srv/runner/inventory/${{ inputs.TAG_OR_UNIQUE_NAME }}-inventory.ec2 TAG_OR_UNIQUE_NAME=${{ inputs.TAG_OR_UNIQUE_NAME }} PLATFORM=${{ inputs.PLATFORM }} CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
container_make_target: "test/provision TERRAFORM_STATE_KEY=${{ inputs.TAG_OR_UNIQUE_NAME }} PREFIX=pkg-tests INVENTORY_OUTPUT=/srv/runner/inventory/${{ inputs.TAG_OR_UNIQUE_NAME }}-inventory.ec2 TAG_OR_UNIQUE_NAME=${{ inputs.TAG_OR_UNIQUE_NAME }} PLATFORM=${{ inputs.PLATFORM }} CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "test/provision/clean TAG_OR_UNIQUE_NAME=${{ inputs.TAG_OR_UNIQUE_NAME }}"
container_make_target: "test/provision/clean TERRAFORM_STATE_KEY=${{ inputs.TAG_OR_UNIQUE_NAME }} TAG_OR_UNIQUE_NAME=${{ inputs.TAG_OR_UNIQUE_NAME }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "test/provision/clean TAG_OR_UNIQUE_NAME=${{ inputs.TAG_OR_UNIQUE_NAME }}"
container_make_target: "test/provision/clean TERRAFORM_STATE_KEY=${{ inputs.TAG_OR_UNIQUE_NAME }} TAG_OR_UNIQUE_NAME=${{ inputs.TAG_OR_UNIQUE_NAME }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/prerelease_canaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,32 @@ jobs:
CROWDSTRIKE_CLIENT_SECRET: ${{secrets.CROWDSTRIKE_CLIENT_SECRET}}
CROWDSTRIKE_CUSTOMER_ID: ${{secrets.CROWDSTRIKE_CUSTOMER_ID}}

get_previous_tag:
runs-on: ubuntu-20.04
# Map a step output to a job output
outputs:
previous_tag: ${{ steps.previous_tag_step.outputs.PREVIOUS_TAG }}
steps:
- id: previous_tag_step
run: .github/workflows/scripts/previous_version.sh ${{ inputs.TAG }} >> "$GITHUB_OUTPUT"

prune-previous-canaries-linux:
needs: get_previous_tag
if: ${{ github.event.inputs.prune == 'true' && github.event.inputs.linux == 'true' }}
uses: ./.github/workflows/component_canaries_prune.yml
with:
PLATFORM: "linux"
TAG: ${{ needs.get_previous_tag.outputs.previous_tag }}
secrets:
AWS_VPC_SUBNET: ${{secrets.AWS_VPC_SUBNET}}

prune-previous-canaries-windows:
needs: get_previous_tag
if: ${{ github.event.inputs.prune == 'true' && github.event.inputs.windows == 'true' }}
uses: ./.github/workflows/component_canaries_prune.yml
with:
PLATFORM: "windows"
TAG: ${{ needs.get_previous_tag.outputs.previous_tag }}
secrets:
AWS_VPC_SUBNET: ${{secrets.AWS_VPC_SUBNET}}

Expand All @@ -94,4 +107,4 @@ jobs:
with:
TAG: ${{ github.event.inputs.tag }}
secrets:
AWS_VPC_SUBNET: ${{secrets.AWS_VPC_SUBNET}}
AWS_VPC_SUBNET: ${{secrets.AWS_VPC_SUBNET}}
21 changes: 21 additions & 0 deletions .github/workflows/scripts/previous_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

# this script accetps a tag as input and it will search and output for the previous one
# for GHA
# if no tag is passed as parameter, the latest one will be used

# fetch the history (including tags) from within a shallow clone like CI-GHA
# supress error when the repository is a complete one.
git fetch --prune --unshallow 2> /dev/null || true

TAG=$1
if [ -z $TAG ];then
TAG=$( git tag | grep -E "^[0-9]+\.[0-9]+\.[0-9]$" | sort | tail -n 1 )
fi

# print previous tag
PREVIOUS_TAG=$( git tag | grep -E "^[0-9]+\.[0-9]+\.[0-9]$" | sort | grep -B 1 $TAG | head -n 1 )

echo "PREVIOUS_TAG=$PREVIOUS_TAG"
Loading

0 comments on commit dd04892

Please sign in to comment.