Skip to content

Commit

Permalink
Converted s3-deploy to use concord-consortium/s3-deploy-action@v1
Browse files Browse the repository at this point in the history
  • Loading branch information
dougmartin committed Oct 17, 2023
1 parent 2be5946 commit 344856d
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 145 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release Production
on:
workflow_dispatch:
inputs:
version:
description: The git tag for the version to use for index.html
required: true
env:
BUCKET: models-resources
PREFIX: researcher-reports
SRC_FILE: index-top.html
DEST_FILE: index.html
jobs:
release:
runs-on: ubuntu-latest
steps:
- run: >
aws s3 cp
s3://${{ env.BUCKET }}/${{ env.PREFIX }}/version/${{ github.event.inputs.version }}/${{ env.SRC_FILE }}
s3://${{ env.BUCKET }}/${{ env.PREFIX }}/${{ env.DEST_FILE }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
24 changes: 24 additions & 0 deletions .github/workflows/release-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release Staging
on:
workflow_dispatch:
inputs:
version:
description: The git tag for the version to use for index-staging.html
required: true
env:
BUCKET: models-resources
PREFIX: researcher-reports
SRC_FILE: index-top.html
DEST_FILE: index-staging.html
jobs:
release:
runs-on: ubuntu-latest
steps:
- run: >
aws s3 cp
s3://${{ env.BUCKET }}/${{ env.PREFIX }}/version/${{ github.event.inputs.version }}/${{ env.SRC_FILE }}
s3://${{ env.BUCKET }}/${{ env.PREFIX }}/${{ env.DEST_FILE }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
31 changes: 16 additions & 15 deletions .github/workflows/researcher-reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,26 @@ jobs:
name: S3 Deploy
needs:
- build_test
# - cypress
runs-on: ubuntu-18.04
#- cypress
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'
- name: Install Dependencies
run: |
gem install s3_website -v 3.4.0
npm ci
- name: Build
run: npm run build
- name: Deploy
run: ./s3_deploy.sh
run: npm ci
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# skip installing cypress since it isn't needed for just building
# This decreases the deploy time quite a bit
CYPRESS_INSTALL_BINARY: 0
- uses: concord-consortium/s3-deploy-action@v1
with:
bucket: models-resources
prefix: researcher-reports
awsAccessKeyId: ${{ secrets.AWS_ACCESS_KEY_ID }}
awsSecretAccessKey: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Parameters to GHActions have to be strings, so a regular yaml array cannot
# be used. Instead the `|` turns the following lines into a string
topBranches: |
["master"]
10 changes: 5 additions & 5 deletions researcher-reports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ To deploy a production release:
4. Run `npm run build`
5. Copy asset size markdown table from previous release and change sizes to match new sizes in `dist`
6. Create `release-<version>` branch and commit changes, push to GitHub, create PR and merge
7. Checkout master and pull
8. Checkout production
9. Run `git merge master --no-ff`
10. Push production to GitHub
11. Use https://github.com/concord-consortium/starter-projects/releases to create a new release tag
7. Test the master build at: https://researcher-reports.concord.org/index-master.html
8. Push a version tag to GitHub and/or use https://github.com/concord-consortium/researcher-reports/releases to create a new GitHub release
9. Stage the release by running the [Release Staging Workflow](https://github.com/concord-consortium/researcher-reports/actions/workflows/release-staging.yml) and entering the version tag you just pushed.
10. Test the staged release at https://researcher-reports.concord.org/index-staging.html
11. Update production by running the [Release Workflow](https://github.com/concord-consortium/researcher-reports/actions/workflows/release.yml) and entering the release version tag.

### Testing

Expand Down
100 changes: 0 additions & 100 deletions researcher-reports/s3_deploy.sh

This file was deleted.

25 changes: 0 additions & 25 deletions researcher-reports/s3_website.yml

This file was deleted.

9 changes: 9 additions & 0 deletions researcher-reports/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

// DEPLOY_PATH is set by the s3-deploy-action its value will be:
// `branch/[branch-name]/` or `version/[tag-name]/`
const DEPLOY_PATH = process.env.DEPLOY_PATH;

module.exports = (env, argv) => {
const devMode = argv.mode !== 'production';

Expand Down Expand Up @@ -124,6 +128,11 @@ module.exports = (env, argv) => {
template: 'src/index.html',
favicon: 'src/public/favicon.ico'
}),
...(DEPLOY_PATH ? [new HtmlWebpackPlugin({
filename: "index-top.html",
template: "src/index.html",
publicPath: DEPLOY_PATH,
})] : []),
new CleanWebpackPlugin(),
]
};
Expand Down

0 comments on commit 344856d

Please sign in to comment.