Merge pull request #90 from axiomhq/fix-ci-issues #21
Workflow file for this run
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: Release | |
permissions: | |
id-token: write | |
contents: read | |
on: | |
push: | |
tags: | |
- "v*" | |
env: | |
YQ_VERSION: "4.25.1" | |
jobs: | |
release-code: | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- uses: actions/checkout@v4 | |
- run: zip -r forwarder.zip src | |
- uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: "latest" | |
prerelease: true | |
title: "Production Build" | |
files: | | |
forwarder.zip | |
release: | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- uses: actions/checkout@v4 | |
- run: wget https://github.com/mikefarah/yq/releases/download/v$YQ_VERSION/yq_linux_amd64.tar.gz -O - | tar xz && mv yq_linux_amd64 /usr/local/bin/yq | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: eu-west-1 | |
role-to-assume: arn:aws:iam::694952825951:role/axiom-cloudwatch-forwarder-release-20241007163724313800000001 | |
role-session-name: release_to_prod | |
- name: Zip code directory | |
run: cd src && zip forwarder.zip *.py | |
- name: Release code to Production | |
run: aws s3 cp --acl public-read ./src/forwarder.zip s3://axiom-cloudformation/axiom-cloudwatch-forwarder/${{ github.ref_name }}/ | |
- run: mkdir build | |
- run: | |
yq '.Resources.ForwarderLambda.Properties.Code.S3Bucket = "axiom-cloudformation" | | |
.Resources.ForwarderLambda.Properties.Code.S3Key = "axiom-cloudwatch-forwarder/${{ github.ref_name }}/forwarder.zip"' cloudformation-stacks/forwarder.template.yaml > build/axiom-cloudwatch-forwarder-${{ github.ref_name }}-cloudformation-stack.yaml | |
- run: | |
yq '.Resources.SubscriberLambda.Properties.Code.S3Bucket = "axiom-cloudformation" | | |
.Resources.SubscriberLambda.Properties.Code.S3Key = "axiom-cloudwatch-forwarder/${{ github.ref_name }}/forwarder.zip"' cloudformation-stacks/subscriber.template.yaml > build/axiom-cloudwatch-subscriber-${{ github.ref_name }}-cloudformation-stack.yaml | |
- run: | |
yq '.Resources.UnsubscriberLambda.Properties.Code.S3Bucket = "axiom-cloudformation" | | |
.Resources.UnsubscriberLambda.Properties.Code.S3Key = "axiom-cloudwatch-forwarder/${{ github.ref_name }}/forwarder.zip"' cloudformation-stacks/unsubscriber.template.yaml > build/axiom-cloudwatch-unsubscriber-${{ github.ref_name }}-cloudformation-stack.yaml | |
- run: | |
yq '.Resources.ListenerLambda.Properties.Code.S3Bucket = "axiom-cloudformation" | | |
.Resources.ListenerLambda.Properties.Code.S3Key = "axiom-cloudwatch-forwarder/${{ github.ref_name }}/forwarder.zip"' cloudformation-stacks/listener.template.yaml > build/axiom-cloudwatch-listener-${{ github.ref_name }}-cloudformation-stack.yaml | |
- name: Release stacks to Production | |
env: | |
SOURCE_DIR: build | |
AWS_S3_BUCKET: "axiom-cloudformation" | |
DEST_DIR: "stacks" | |
run: aws s3 sync --acl public-read ./$SOURCE_DIR s3://$AWS_S3_BUCKET/$DEST_DIR |