-
Notifications
You must be signed in to change notification settings - Fork 7
64 lines (60 loc) · 3.08 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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: cd src && zip forwarder.zip *.py
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Production Build"
files: |
src/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