Skip to content

Commit

Permalink
test: Deploy as part of CI
Browse files Browse the repository at this point in the history
Ensures that deployment works rather than relying on "invisible"
post-merge deployment.

Destroys CI stack after run, retrying in case it's in an intermediate
state.

Unfortunately serverless doesn't support variables in the service name
<serverless/serverless#9813>, so we can't have
more than one CI environment deployed at any one time.

Keep the DynamoDB table only in production.
  • Loading branch information
l0b0 committed Mar 13, 2023
1 parent 7d779ba commit 6c3dc65
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 221 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/deploy-production.yml
@@ -0,0 +1,94 @@
name: Deploy production instance

on:
push:
branches:
- master

jobs:
deploy:
if: startsWith(github.ref, 'refs/tags/v')
concurrency:
group: ${{ github.workflow }}
runs-on: ubuntu-22.04
steps:

- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- name: Get Python version
run: echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"

- name: Use Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache pip
uses: actions/cache@v3.2.6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('./poetry.lock') }}
restore-keys: ${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ env.PYTHON_VERSION }}-

- name: Build project
run: |
echo ${{ github.repository }}
zip -r qgis-plugin-repository.zip .
- name: Create Release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
See [CHANGELOG](https://github.com/linz/qgis-plugin-repository/blob/master/CHANGELOG.md) for detailed release information.
draft: false
prerelease: false

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./qgis-plugin-repository.zip
asset_name: qgis-plugin-repository
asset_content_type: application/zip

- name: Configure AWS Prd Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_PRD }}

- name: Get Node.js version
run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_ENV"

- name: Install Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache Node.js packages
uses: actions/cache@v3.2.6
with:
path: ~/.npm
key:
${{ runner.os }}-node-${{ secrets.CACHE_SEED }}-${{ hashFiles('./package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ secrets.CACHE_SEED }}-
- name: install serverless
run: npm install

- name: deploy app
run: npx serverless deploy --stage=dev --param=resource-suffix=56c159c6dfdsw2378fec41dfd
218 changes: 0 additions & 218 deletions .github/workflows/push.yml

This file was deleted.

0 comments on commit 6c3dc65

Please sign in to comment.