Skip to content

Get cost splitting report #36

Get cost splitting report

Get cost splitting report #36

name: "Get cost splitting report"
on:
workflow_dispatch:
inputs:
email_recipients:
description: 'Comma separated list of emails that you want the link to the reports being sent to'
type: string
schedule:
- cron: '0 0 1 * *'
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
SMTP_SENDER: ${{ secrets.SMTP_SENDER }}
SMTP_USER: ${{ secrets.SMTP_USER }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
SMTP_SERVER: ${{ secrets.SMTP_SERVER}}
SMTP_PORT: ${{ secrets.SMTP_PORT}}
EMAIL_RECIPIENTS: ${{ inputs.email_recipients }}
permissions:
id-token: write
contents: write
pull-requests: write
defaults:
run:
shell: bash
working-directory: ./scripts/cost-splitting
jobs:
create-report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.OIDC_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install the project dependencies
run: poetry install
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Run the report creation
run: poetry run python script.py
env:
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit --allow-empty -m "Updating the storage report"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}