From 4239e290dec21a5874e94bb5932f837dbd28b053 Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Wed, 9 Oct 2024 13:23:52 +0100 Subject: [PATCH 1/5] Initial build and deploy workflow --- .github/workflows/main.yml | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..6016801f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,63 @@ +name: S3/CloudFront deployment beta.carpentries.org + +on: + push: + branches: main + schedule: + - cron: '30 */6 * * *' + workflow_dispatch: + +jobs: + build-website: + if: github.repository_owner == 'carpentries' + runs-on: ubuntu-22.04 + + defaults: + run: + shell: bash + + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: true # Fetch Hugo themes (true OR recursive) + fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v3 + with: + hugo-version: 'latest' + extended: true + + - name: Update Theme + run: | + hugo mod get -u github.com/carpentries/carpentries-hugo-theme + hugo mod npm pack + + - name: Build + run: hugo --minify + + - name: List Built Files + run: ls "$GITHUB_WORKSPACE/public/" + + - name: Deploy to AWS S3 + id: deploy + uses: fmichonneau/s3-sync-action@log-output + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + SOURCE_DIR: public/ + + - name: Invalidate CloudFront + uses: chetan/invalidate-cloudfront-action@master + env: + PATHS: /* + AWS_REGION: 'us-east-1' + DISTRIBUTION: ${{ secrets.DISTRIBUTION }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From e97a8e8cc069561fd169344351e5d4d309aa6844 Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Wed, 9 Oct 2024 13:54:56 +0100 Subject: [PATCH 2/5] Update main.yml --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6016801f..d704f52e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,6 +25,10 @@ jobs: submodules: true # Fetch Hugo themes (true OR recursive) fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Setup Hugo uses: peaceiris/actions-hugo@v3 with: From e749dffcb535935127b2653e9df3d3161d1eaf70 Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Mon, 21 Oct 2024 14:17:37 +0100 Subject: [PATCH 3/5] Update main.yml Disable carpentries check for testing --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d704f52e..beb305d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ on: jobs: build-website: - if: github.repository_owner == 'carpentries' + # if: github.repository_owner == 'carpentries' runs-on: ubuntu-22.04 defaults: From 5098c824923aae43f0d1dbf8c3d97f484390089f Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Mon, 21 Oct 2024 14:26:18 +0100 Subject: [PATCH 4/5] Update main.yml Add intersect dep --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index beb305d7..794da400 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,6 +35,10 @@ jobs: hugo-version: 'latest' extended: true + - name: Install NPM deps + run: | + npm install @alpinejs/intersect + - name: Update Theme run: | hugo mod get -u github.com/carpentries/carpentries-hugo-theme From a88c8520f5d0b16801c2091e8616a423f61370e8 Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Mon, 21 Oct 2024 14:57:04 +0100 Subject: [PATCH 5/5] Update main.yml Re-enable repo owner check --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 794da400..c30e599d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ on: jobs: build-website: - # if: github.repository_owner == 'carpentries' + if: github.repository_owner == 'carpentries' runs-on: ubuntu-22.04 defaults: