diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 365573a..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: deploy - -on: -# release: -# types: [published, deleted] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - # Unzip, synth & deploy - deploy: - runs-on: ubuntu-latest - - steps: - - id: latest - uses: thebritican/fetch-latest-release@v1.0.3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - uses: actions/checkout@v2 - with: - ref: ${{ steps.latest.outputs.tag_name }} - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: '14' - - - name: NPM install for Serverless - run: npm install - - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: Install Poetry - uses: Gr1N/setup-poetry@v4 - - - name: Cache Poetry virtualenv - uses: actions/cache@v2 - with: - path: ~/.cache/pypoetry/virtualenvs - key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} - - - name: Install discord_app Poetry - run: cd discord_app && poetry install - if: steps.cache.outputs.cache-hit != 'true' - - - name: Package discord_app - run: cd discord_app/ && npx serverless package && cd ../ - - - name: Package error_parser_function - run: cd error_parser_function/ && npx serverless package && cd ../ - - - name: Install infra Poetry - run: cd infra && poetry install - if: steps.cache.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 }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7513f70..995b54d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -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/ @@ -102,7 +108,7 @@ jobs: name: infra path: infra/ - release: + deploy: needs: build runs-on: ubuntu-latest steps: @@ -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/install-poetry@v1.0.0 + 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/install-poetry@v1.0.0 + 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 }} diff --git a/discord_app/pyproject.toml b/discord_app/pyproject.toml index 9ca333a..957030f 100644 --- a/discord_app/pyproject.toml +++ b/discord_app/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "discord_app" -version = "0.8.0" +version = "1.0" description = "" authors = ["lesteenman "]