mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-08-21 14:51:40 -07:00
Merges to main don't get posted to main && it should be clearer how branches are deployed (#415)
* fixes #319 - merges to main still don't get posted to /main , and #362 It should be clearer how branches are deployed -- move to using 'pull_request' instead of 'push' (we can't push to master directly anyhow), and run on 'closed'; also add comment on PR itself * updating to add subsequent pushes to the same PR
This commit is contained in:
parent
67b39475f7
commit
a787bd71ab
1 changed files with 23 additions and 6 deletions
29
.github/workflows/build_deploy.yml
vendored
29
.github/workflows/build_deploy.yml
vendored
|
@ -6,12 +6,15 @@
|
||||||
|
|
||||||
name: GH Pages deploy
|
name: GH Pages deploy
|
||||||
on:
|
on:
|
||||||
push:
|
pull_request:
|
||||||
|
types: [ closed, opened ]
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- 'client/**/*'
|
- 'client/**/*'
|
||||||
pull_request:
|
push:
|
||||||
branches: [main]
|
branches:
|
||||||
|
- '*' # Run on all updates to PR branches
|
||||||
|
- '!main' # Do not run on pushes to main
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -30,7 +33,7 @@ jobs:
|
||||||
# If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main"
|
# If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main"
|
||||||
# This variable is used by gatsby-config.js to set a prefixPath
|
# This variable is used by gatsby-config.js to set a prefixPath
|
||||||
- name: Set DESTINATION_FOLDER for main
|
- name: Set DESTINATION_FOLDER for main
|
||||||
if: github.event.pull_request.merged == true
|
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
|
||||||
run: |
|
run: |
|
||||||
echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV
|
echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV
|
||||||
- name: Set DESTINATION_FOLDER for branch
|
- name: Set DESTINATION_FOLDER for branch
|
||||||
|
@ -72,7 +75,7 @@ jobs:
|
||||||
path: ./public
|
path: ./public
|
||||||
# If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main"
|
# If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main"
|
||||||
- name: Set DESTINATION_FOLDER for main
|
- name: Set DESTINATION_FOLDER for main
|
||||||
if: github.event.pull_request.merged == true
|
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
|
||||||
run: |
|
run: |
|
||||||
echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV
|
echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV
|
||||||
- name: Set DESTINATION_FOLDER for branch
|
- name: Set DESTINATION_FOLDER for branch
|
||||||
|
@ -82,7 +85,6 @@ jobs:
|
||||||
- name: Deploy to Github Pages
|
- name: Deploy to Github Pages
|
||||||
uses: JamesIves/github-pages-deploy-action@4.1.0
|
uses: JamesIves/github-pages-deploy-action@4.1.0
|
||||||
with:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
BRANCH: gh-pages # The branch the action should deploy to.
|
BRANCH: gh-pages # The branch the action should deploy to.
|
||||||
FOLDER: public # The folder the action should deploy.
|
FOLDER: public # The folder the action should deploy.
|
||||||
TARGET-FOLDER: ${{env.DESTINATION_FOLDER}} # If we're on a PR branch, merge to PR folder
|
TARGET-FOLDER: ${{env.DESTINATION_FOLDER}} # If we're on a PR branch, merge to PR folder
|
||||||
|
@ -95,3 +97,18 @@ jobs:
|
||||||
aws-region: us-east-1
|
aws-region: us-east-1
|
||||||
- name: Deploy to Geoplatform AWS
|
- name: Deploy to Geoplatform AWS
|
||||||
run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --delete
|
run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --delete
|
||||||
|
- name: Update PR with deployed URL
|
||||||
|
uses: mshick/add-pr-comment@v1
|
||||||
|
if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event_name == 'push' # Only comment if the PR has been opened or a push has updated it
|
||||||
|
with:
|
||||||
|
message: |
|
||||||
|
**🚢 PR Deployed! 🚢**
|
||||||
|
Find it here: https://d2zjid6n5ja2pt.cloudfront.net/justice40-tool/${{env.DESTINATION_FOLDER}}/en/cejst/ !
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
|
||||||
|
allow-repeats: false # This is the default
|
||||||
|
- name: Printing deployment URLs
|
||||||
|
run: |
|
||||||
|
echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en"
|
||||||
|
echo "Standard S3 bucket version (http only) : http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/justice40-tool/$DESTINATION_FOLDER/en"
|
||||||
|
echo "Cloudfront https: https://d2zjid6n5ja2pt.cloudfront.net/justice40-tool/$DESTINATION_FOLDER/en"
|
Loading…
Add table
Add a link
Reference in a new issue