Merge pull request #102 from lesteenman/renovate/moto-4.x-lockfile #75
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: main | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install poetry | |
uses: snok/install-poetry@v1.3.3 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '14' | |
- name: Load cached venv for discord-app | |
id: cached-discord-app-poetry | |
uses: actions/cache@v3 | |
with: | |
path: | | |
discord_app/.venv | |
key: venv-${{ runner.os }}-${{ hashFiles('discord_app/poetry.lock') }} | |
- name: Poetry install for discord_app/ | |
run: cd discord_app && poetry install | |
if: steps.cached-discord-app-poetry.outputs.cache-hit != 'true' | |
- name: Load cached venv for infra | |
id: cached-infra-poetry | |
uses: actions/cache@v3 | |
with: | |
path: infra/.venv | |
key: venv-${{ runner.os }}-${{ hashFiles('infra/poetry.lock') }} | |
- name: Poetry install for infra/ | |
run: cd infra && poetry install | |
if: steps.cached-infra-poetry.outputs.cache-hit != 'true' | |
- name: Load cached node modules | |
id: cached-node-modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules/ | |
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | |
- name: Npm install | |
run: npm install | |
if: steps.cached-node-modules.outputs.cache-hit != 'true' | |
- name: Flake8 | |
run: cd discord_app && poetry run flake8 --config ../.flake8 ./tests ./eternal_guesses ../error_parser_function ../infra | |
- name: Pytest | |
run: cd discord_app && poetry run coverage run -m pytest && poetry run coverage xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: discord_app/coverage.xml | |
fail_ci_if_error: true | |
path_to_write_report: ./coverage/codecov_report.txt | |
verbose: true | |
- name: Create artifact for the infra module | |
uses: actions/upload-artifact@v3 | |
with: | |
name: infra | |
path: infra/ | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: Production | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install poetry | |
uses: snok/install-poetry@v1.3.3 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Load cached venv for infra | |
id: cached-infra-poetry | |
uses: actions/cache@v3 | |
with: | |
path: infra/.venv | |
key: venv-${{ runner.os }}-${{ hashFiles('infra/poetry.lock') }} | |
- name: Poetry install for infra/ | |
run: cd infra && poetry install | |
if: steps.cached-infra-poetry.outputs.cache-hit != 'true' | |
- name: Synthesize CDK | |
run: cd infra && poetry run npx cdk synth --output build/cdk.out | |
env: | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_TARGET_ACCOUNT: ${{ secrets.AWS_TARGET_ACCOUNT }} | |
DISCORD_PUBLIC_KEY: ${{ secrets.DISCORD_PUBLIC_KEY }} | |
DISCORD_APPLICATION_ID: ${{ secrets.DISCORD_APPLICATION_ID }} | |
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }} | |
NOTIFICATION_EMAIL: ${{ secrets.NOTIFICATION_EMAIL }} | |
APP_LOG_LEVEL: ${{ secrets.APP_LOG_LEVEL }} | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.AWS_DEPLOYMENT_ROLE }} | |
role-session-name: github-actions-deployment | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Deploy CDK | |
run: cd infra && poetry run npx cdk deploy --app ./build/cdk.out --require-approval never | |
- name: Poetry install for / | |
run: poetry install | |
- name: Update commands | |
run: poetry run ./bin/register_commands.py | |
env: | |
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }} | |
DISCORD_APPLICATION_ID: ${{ secrets.DISCORD_APPLICATION_ID }} | |
release: | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install poetry | |
uses: snok/install-poetry@v1.3.3 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Build Changelog | |
id: changes | |
run: echo "::set-output name=changelog::$(git log --format=%B -1)" | |
- name: Get the base version | |
id: release_version | |
run: echo "::set-output name=version::$(cd discord_app && poetry version -s)" | |
- name: Get the date of the release | |
id: release_date | |
run: echo "::set-output name=date::$(date +"%Y-%m-%d")" | |
- name: Get the shorthash of the commit | |
id: release_hash | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Check changelog | |
run: echo ${{ steps.changes.outputs.changelog }} | |
- name: Check release name | |
run: echo "v${{ steps.release_version.outputs.version }}.${{ steps.release_date.outputs.date }}.${{ steps.release_hash.outputs.sha_short }}" | |
- name: Create Release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: "v${{ steps.release_version.outputs.version }}.${{ steps.release_date.outputs.date }}.${{ steps.release_hash.outputs.sha_short }}" | |
release_name: "v${{ steps.release_version.outputs.version }}.${{ steps.release_date.outputs.date }}.${{ steps.release_hash.outputs.sha_short }}" | |
body: ${{ steps.changes.outputs.changelog }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |