Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Bump express from 4.17.1 to 4.17.3 #64

Bump express from 4.17.1 to 4.17.3

Bump express from 4.17.1 to 4.17.3 #64

Workflow file for this run

name: github-actions-deploy
on:
push:
branches:
- "master"
pull_request:
types: [ opened, synchronize, reopened, closed ]
env:
PRODUCTION_BRANCH: "master"
REPO_NAME: ${{ github.event.repository.name }}
PULL_REQUEST_NUMBER: ${{ github.event.number }}
GITHUB_ACTION: ${{ github.event.action }}
AWS_REGION: "us-east-1"
SERVICE_NAME: "badges"
REPO_OWNER: "FormidableLabs"
GITHUB_HASH: ${{ github.event.after }}
jobs:
destroy:
if: (github.event_name == 'pull_request') && (github.event.action == 'closed')
runs-on: ubuntu-latest
steps:
- name: Checkout the Repository
uses: actions/checkout@v2
- 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: us-east-1
- name: Set environment variables
run: |
echo "TIER=nonprod" >> $GITHUB_ENV
echo "STAGE=pr$PULL_REQUEST_NUMBER" >> $GITHUB_ENV
- name: Run the install script
run: bash scripts/install.sh
- name: Destroy Terraform
run: terragrunt destroy --auto-approve --terragrunt-non-interactive --terragrunt-working-dir terraform/app
- name: Yarn Serverless Remove
run: yarn sls remove
build:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout the Repository
uses: actions/checkout@v2
- 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: us-east-1
- name: Set environment variables
# https://stackoverflow.com/questions/59882715/use-environment-variable-in-github-action-if
# https://www.techiediaries.com/get-current-branch-name-github-actions-github_ref-bash/
run: |
if [[ $GITHUB_EVENT_NAME != 'pull_request' ]]; then
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/\//-/')
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
if [[ "${GITHUB_REF#refs/heads/}" == $PRODUCTION_BRANCH ]]; then
TIER="prod"
STAGE="production"
else
TIER="nonprod"
STAGE="pr$PULL_REQUEST_NUMBER"
fi
else
TIER="nonprod"
STAGE="pr$PULL_REQUEST_NUMBER"
fi
echo "TIER=$TIER" >> $GITHUB_ENV
echo "STAGE=$STAGE" >> $GITHUB_ENV
echo "ZIP_FILE=artifact-$REPO_NAME-$TIER-$STAGE.zip" >> $GITHUB_ENV
AWS_ACCOUNT=$(aws sts get-caller-identity | jq -r .Account)
echo "BUCKET_NAME=tf-$REPO_NAME-$TIER-artifacts-$AWS_ACCOUNT" >> $GITHUB_ENV
- name: Run the install script
run: bash scripts/install.sh
- name: Yarn test
run: yarn test
- name: Yarn package
run: yarn sls package
- name: Copy the serverless artifact file
run: cp .serverless/sls-*.zip serverless-artifact.zip
# TODO
# Previously made sure that the CloudFormation stack was in a "ready" state before proceeding
# Made sure that the stack wasn't in a failed state
# Also used to make sure that the current commit was the most recent
# Both of these do not seem very helpful with the move to GitHub Actions
- name: Deploy serverless
run: yarn sls deploy --package .serverless
- name: Apply Terraform
run: |
terragrunt apply --auto-approve --terragrunt-non-interactive --terragrunt-working-dir terraform/app
- name: Create a zip file of artifacts
run: zip $ZIP_FILE scripts terraform/**/*.{tf,hcl} .terraform-version serverless-artifact.zip serverless.yml package.json yarn.lock
- name: Upload Artifact Zip File to S3
run: aws s3 cp $ZIP_FILE s3://$BUCKET_NAME/$ZIP_FILE
- name: Post comment on pull request
uses: actions/[email protected]
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const endpoint=`https://${process.env.REPO_NAME}-${process.env.TIER}-pr${process.env.PULL_REQUEST_NUMBER}.freetls.fastly.net`
examples = [
'size/github/FormidableLabs/react-fast-compare/master/index.js',
'size/npm/victory/dist/victory.min.js?gzip=true',
'browsers?firefox=20,26&iexplore=!8,-9,10',
'travis/infernojs/inferno/sauce/Havunen?name=InfernoJS',
'sauce/Havunen?labels=none'
]
.map(example => ({ example, url: `${endpoint}/${example}` }))
.map(
({ example, url }) =>
`- [\`${example}\`](${url}) [![example](${url})](${url})`
)
.join('\n');
const output = `## PR Deployment
Deployed PR environment to \`${endpoint}\`
### Examples
${examples}
### Deployment
If it's ready to be deployed to production, merge to the master branch`
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})