Skip to content

Commit

Permalink
Merge 65edae4 into 4b52d65
Browse files Browse the repository at this point in the history
  • Loading branch information
lesteenman authored Mar 6, 2021
2 parents 4b52d65 + 65edae4 commit b9f6687
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 86 deletions.
79 changes: 0 additions & 79 deletions .github/workflows/deploy.yml

This file was deleted.

91 changes: 85 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
branches: [ main ]

# TODO: REMOVE THIS AGAIN
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand Down Expand Up @@ -34,7 +38,9 @@ jobs:
id: cached-discord-app-poetry
uses: actions/cache@v2
with:
path: discord_app/.venv
path: |
discord_app/.venv
discord_app/.serverless/cache
key: venv-${{ runner.os }}-${{ hashFiles('discord_app/poetry.lock') }}

- name: Poetry install for discord_app/
Expand Down Expand Up @@ -102,7 +108,7 @@ jobs:
name: infra
path: infra/

release:
deploy:
needs: build
runs-on: ubuntu-latest
steps:
Expand All @@ -123,19 +129,92 @@ jobs:
with:
name: error-parser-package

- name: Install Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv for infra
id: cached-infra-poetry
uses: actions/cache@v2
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 }}

- name: Deploy CDK
run: cd infra && npx cdk synth --app ./build/cdk.out --require-approval never
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 }}

release:
needs: build # TODO: do after 'deploy'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Build Changelog
id: changes
run: echo "::set-output name=changeLog::$(git show --format=%B | tail +3)"
run: echo "::set-output name=changelog::$(git log --format=%B -1 | tail +3)"

- 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: ${{ steps.release_name.outputs.date }} ${GITHUB_SHA::7}
release_name: ${{ steps.release_name.outputs.date }} ${GITHUB_SHA::7}
body: ${{steps.changes.outputs.changelog}}
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 }}
2 changes: 1 addition & 1 deletion discord_app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "discord_app"
version = "0.8.0"
version = "1.0"
description = ""
authors = ["lesteenman <[email protected]>"]

Expand Down

0 comments on commit b9f6687

Please sign in to comment.