release #99
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: release | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: Environment to release | |
required: true | |
default: production | |
ref: | |
description: Ref to release | |
required: true | |
default: master | |
repository_dispatch: | |
types: | |
- release | |
jobs: | |
deploy: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.inputs.ref }}${{ github.event.client_payload.ref }} | |
- name: Start deployment | |
uses: bobheadxi/[email protected] | |
id: deployment | |
with: | |
step: start | |
env: ${{ github.event.inputs.environment }}${{ github.event.client_payload.environment }} | |
desc: ${{ github.event.client_payload.ref }}${{ github.event.client_payload.ref }} | |
ref: ${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Get yarn cache directory | |
id: yarn-cache-dir | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Yarn cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.yarn-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Node modules cache | |
uses: actions/cache@v2 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile --non-interactive | |
- name: Move runtime dependencies | |
run: | | |
version=$(jq -r '.devDependencies."@pureskillgg/awsjs"' < package.json) | |
yarn remove @pureskillgg/awsjs | |
yarn add "@pureskillgg/awsjs@${version}" | |
- name: Serverless deploy to production from ${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }} | |
run: yarn run deploy | |
if: ${{ github.event.inputs.environment == 'production' || github.event.client_payload.environment == 'production' }} | |
env: | |
SERVERLESS_STAGE: prod | |
- name: Serverless deploy to staging from ${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }} | |
run: yarn run deploy | |
if: ${{ github.event.inputs.environment == 'staging' || github.event.client_payload.environment == 'staging' }} | |
env: | |
SERVERLESS_STAGE: stg | |
- name: Get commit message | |
id: message | |
run: echo ::set-output name=message::$(git log --format=%B -n 1 ${{ github.sha }}) | |
- name: Grafana Annotation | |
uses: frankie567/[email protected] | |
with: | |
apiHost: ${{ secrets.GRAFANA_API_ORIGIN }} | |
apiToken: ${{ secrets.GRAFANA_API_KEY }} | |
tags: deployment,${{ github.event.repository.name }},${{ github.event.inputs.environment }}${{ github.event.client_payload.environment }} | |
text: | | |
${{ steps.message.outputs.message }} | |
${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }} | |
${{ github.sha }} | |
- name: Get version | |
id: version | |
run: | | |
echo "::set-output name=version::$(jq -r .version < package.json)" | |
- name: Sentry release v${{ steps.version.outputs.version }} to production | |
if: ${{ github.event.inputs.environment == 'production' || github.event.client_payload.environment == 'production' }} | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ github.repository_owner }} | |
SENTRY_PROJECT: ${{ github.event.repository.name }} | |
with: | |
environment: prod | |
version: ${{ steps.version.outputs.version }} | |
version_prefix: ${{ github.event.repository.name }}@ | |
- name: Sentry release v${{ steps.version.outputs.version }} to staging | |
if: ${{ github.event.inputs.environment == 'staging' || github.event.client_payload.environment == 'staging' }} | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ github.repository_owner }} | |
SENTRY_PROJECT: ${{ github.event.repository.name }} | |
with: | |
environment: stg | |
version: ${{ steps.version.outputs.version }} | |
version_prefix: ${{ github.event.repository.name }}@ | |
- name: Get status | |
id: status | |
if: always() | |
run: | | |
if [ "${JOB_STATUS,,}" == 'success' ]; then | |
echo "::set-output name=color::#00ff00" | |
else | |
echo "::set-output name=color::#ff0000" | |
fi | |
env: | |
JOB_STATUS: ${{ job.status }} | |
- name: Notify Discord | |
uses: rtCamp/action-slack-notify@v2 | |
if: always() | |
env: | |
SLACK_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}/slack | |
SLACK_USERNAME: PureSkill.gg Bot | |
SLACK_ICON_EMOJI: ':github:' | |
SLACK_COLOR: ${{ steps.status.outputs.color }} | |
SLACK_ICON: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png | |
SLACK_TITLE: Deployed ${{ github.event.inputs.environment }}${{ github.event.client_payload.environment }} | |
SLACK_MESSAGE: ${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }} | |
SLACK_FOOTER: ${{ github.repository }} | |
- name: Finish deployment | |
uses: bobheadxi/[email protected] | |
if: always() | |
with: | |
step: finish | |
status: ${{ job.status }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
token: ${{ secrets.GITHUB_TOKEN }} |