Skip to content

Commit

Permalink
upload zip file to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
dasfmi committed Sep 30, 2024
1 parent 7feb589 commit 443af34
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 21 deletions.
45 changes: 36 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,67 @@ name: CI

on: [push]

permissions:
id-token: write
contents: read

env:
YQ_VERSION: "4.25.1"

jobs:
python:
runs-on: ubuntu-latest
outputs:
forwarder: ${{ steps.forwarder-package.outputs.artifact-url }}
url: ${{ steps.forwarder-package.outputs.url }}
bucket: ${{ steps.forwarder-package.outputs.bucket }}
key: ${{ steps.forwarder-package.outputs.key }}
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- uses: chartboost/ruff-action@v1
with:
args: "format --check"
- uses: actions/upload-artifact@v4
id: forwarder-package
with:
name: forwarder.zip
path: src/*
retention-days: 1
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-1
role-to-assume: "arn:aws:iam::887822303684:role/axiom_forwarder_github_actions20240222164306574100000002"
role-session-name: release_to_dev
- name: Release to Dev
run: aws s3 sync --acl public-read ./src/ s3://axiom-cloudformation-dev/axiom-cloudwatch-forwarder/v1.0
- name: Set output
id: forwarder-package
run: |
echo "url=s3://axiom-cloudformation-dev/axiom-cloudwatch-forwarder/v1.0" >> "$GITHUB_OUTPUT"
echo "bucket=axiom-cloudformation-dev" >> "$GITHUB_OUTPUT"
echo "key=axiom-cloudwatch-forwarder/v1.0" >> "$GITHUB_OUTPUT"
cloudformation:
runs-on: ubuntu-latest
needs:
- python
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
- run: echo "${{ needs.python.outputs.forwarder }}"
- run: |-
mkdir build
yq ".Resources.ForwarderLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.forwarder }}" cloudformation-stacks/forwarder.template.yaml > build/axiom-cloudwatch-forwarder-cloudformation-stack.yaml
yq ".Resources.SubscriberLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.forwarder }}" cloudformation-stacks/subscriber.template.yaml > build/axiom-cloudwatch-subscriber-cloudformation-stack.yaml
yq ".Resources.UnsubscriberLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.forwarder }}" cloudformation-stacks/unsubscriber.template.yaml > build/axiom-cloudwatch-unsubscriber-cloudformation-stack.yaml
yq ".Resources.ListenerLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.forwarder }}" cloudformation-stacks/listener.template.yaml > build/axiom-cloudwatch-listener-cloudformation-stack.yaml
- run: echo "${{ needs.python.outputs.bucket }}"
- run: echo "${{ needs.python.outputs.url }}"
- run: mkdir build
- run:
yq '.Resources.ForwarderLambda.Properties.Code.S3Bucket = "${{ needs.python.outputs.bucket }}" |
.Resources.ForwarderLambda.Properties.Code.S3key = "${{ needs.python.outputs.key }}"' cloudformation-stacks/forwarder.template.yaml > build/axiom-cloudwatch-forwarder-cloudformation-stack.yaml
- run:
yq '.Resources.SubscriberLambda.Properties.Code.S3Bucket = "${{ needs.python.outputs.bucket }}" |
.Resources.SubscriberLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.key }}"' cloudformation-stacks/subscriber.template.yaml > build/axiom-cloudwatch-subscriber-cloudformation-stack.yaml
- run:
yq '.Resources.UnsubscriberLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.bucket }}" |
.Resources.UnsubscriberLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.key }}"' cloudformation-stacks/unsubscriber.template.yaml > build/axiom-cloudwatch-unsubscriber-cloudformation-stack.yaml
- run:
yq '.Resources.ListenerLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.bucket }}" |
.Resources.ListenerLambda.Properties.Code.ZipFile = "${{ needs.python.outputs.key }}"' cloudformation-stacks/listener.template.yaml > build/axiom-cloudwatch-listener-cloudformation-stack.yaml
- run: cat build/*
- uses: actions/upload-artifact@v4
with:
Expand Down
5 changes: 2 additions & 3 deletions cloudformation-stacks/forwarder.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ Resources:
Runtime: python3.9
Handler: index.lambda_handler
Code:
ZipFile: |
# DO NOT EDIT
# CI will replace these comments with the code from ./forwarder.py
S3Bucket: "" # CI will replace these comments with the code from src/forwarder.py
S3Key: ""
Role: !GetAtt
- ForwarderRole
- Arn
Expand Down
5 changes: 2 additions & 3 deletions cloudformation-stacks/listener.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ Resources:
Runtime: python3.9
Handler: index.lambda_handler
Code:
ZipFile: |
# DO NOT EDIT
# CI will replace these comments with the code from ./listener.py
S3Bucket: "" # CI will replace these comments with the code from src/forwarder.py
S3Key: ""
Role: !GetAtt
- ListenerRole
- Arn
Expand Down
5 changes: 2 additions & 3 deletions cloudformation-stacks/subscriber.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ Resources:
Handler: index.lambda_handler
Timeout: 300
Code:
ZipFile: |
# DO NOT EDIT
# CI will replace these comments with the code from ./subscriber.py
S3Bucket: "" # CI will replace these comments with the code from src/forwarder.py
S3Key: ""
Role: !GetAtt
- SubscriberRole
- Arn
Expand Down
5 changes: 2 additions & 3 deletions cloudformation-stacks/unsubscriber.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ Resources:
Handler: index.lambda_handler
Timeout: 300
Code:
ZipFile: |
# DO NOT EDIT
# CI will replace these comments with the code from ./unsubscriber.py
S3Bucket: "" # CI will replace these comments with the code from src/forwarder.py
S3Key: ""
Role: !GetAtt
- UnsubscriberRole
- Arn
Expand Down

0 comments on commit 443af34

Please sign in to comment.