Created
June 10, 2023 21:04
-
-
Save danieltharp/314b15696893e3acb3899d4904705c72 to your computer and use it in GitHub Desktop.
Push a static site to an S3 bucket with Github Actions
This file contains hidden or 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: Deploy to AWS | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ develop, main ] | |
paths: | |
- 'apps/io/**' | |
- '.github/workflows/io.yaml' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
# Runs a single command using the runners shell | |
- name: Setup Node.js | |
uses: actions/[email protected] | |
- name: composer install | |
uses: php-actions/composer@v6 | |
with: | |
args: --working-dir=apps/io | |
# Runs a set of commands using the runners shell | |
- name: Jigsaw Build | |
run: | | |
npm install | |
npm run prod | |
working-directory: apps/io | |
- name: Push built site to S3 | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --delete --acl=public-read | |
env: | |
AWS_S3_BUCKET: 'tharp.io' | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'us-east-1' # optional: defaults to us-east-1 | |
SOURCE_DIR: 'apps/io/build_production' # optional: defaults to entire repository |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment