Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork sp blogpost #238

Merged
merged 9 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 20 additions & 58 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ jobs:

- name: Set env parameters
run: |
echo "issue=${{ github.event.inputs.orig_pr || github.event.pull_request.number }}" >> $GITHUB_ENV
repo_name=${{ github.event.inputs.orig_pr && 'rladies/directory' || github.repository }}
echo "repo_name=$(basename ${repo_name})" >> $GITHUB_ENV
ver=$(cat .Rprofile | grep hugo.version | cut -d"=" -f2 | sed -e s.\"..g | sed -e s.\ ..g | sed -e s.,..g)
echo "hugovr=$ver" >> $GITHUB_ENV
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "directory=${{ github.event.inputs.directory }}" >> $GITHUB_ENV
echo "netalias=${{ github.event.inputs.directory }}" >> $GITHUB_ENV
echo "token=${{ secrets.GLOBAL_GHA_PAT }}" >> $GITHUB_ENV
else
echo "directory=main" >> $GITHUB_ENV
echo "netalias=${{ github.event.number }}" >> $GITHUB_ENV
echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
fi

- name: Install cURL Headers
Expand Down Expand Up @@ -132,79 +137,36 @@ jobs:
- name: Build
run: |
if [[ '${{github.ref}}' == 'refs/heads/main' ]]; then
hugo -d ${{ env.hugobd }}
hugo \
-e production \
-d ${{ env.hugobd }}
else
hugo -d ${{ env.hugobd }} \
-b https://${{ env.netalias }}--rladies-dev.netlify.app/
hugo \
-e development \
-d ${{ env.hugobd }} \
-b https://${{ env.netalias }}--rladies-dev.netlify.app/
fi

- name: Archive Build Artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact-${{ github.run_id }}
path: ${{ env.hugobd }}

deploy-production:
name: Deploy production
needs: build
if: github.ref == 'refs/heads/main' && github.event_name != 'workflow_dispatch'
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: build-artifact-${{ github.run_id }}
path: public

- name: Deploy 🚀
- name: Deploy production 🚀
if: github.ref == 'refs/heads/main' && github.event_name != 'workflow_dispatch'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: public

deploy-preview:
name: Deploy preview
needs: build
if: github.ref != 'refs/heads/main' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-22.04
steps:
- name: Get environment
run: |
echo "issue=${{ github.event.inputs.orig_pr || github.event.pull_request.number }}" >> $GITHUB_ENV
repo_name=${{ github.event.inputs.orig_pr && 'rladies/directory' || github.repository }}
echo "repo_name=$(basename ${repo_name})" >> $GITHUB_ENV
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "token=${{ secrets.GLOBAL_GHA_PAT }}" >> $GITHUB_ENV
echo "netalias=${{ github.event.inputs.directory }}" >> $GITHUB_ENV
else
echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
echo "netalias=${{ github.event.number }}" >> $GITHUB_ENV
fi

- name: Install netlify cli
run: npm install netlify-cli -g

- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: build-artifact-${{ github.run_id }}
path: public
folder: ${{ env.hugobd }}

- name: Deploy Netlify
- name: Deploy Preview
if: github.ref != 'refs/heads/main' || github.event_name == 'workflow_dispatch'
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
npm install netlify-cli -g
netlify deploy \
--alias ${{ env.netalias }} \
--dir=public
--dir=${{ env.hugobd }}

- uses: actions/github-script@v6
if: github.ref != 'refs/heads/main' || github.event_name == 'workflow_dispatch'
name: Notify PR about build
with:
github-token: ${{ env.token }}
Expand Down
3 changes: 1 addition & 2 deletions config/_default/hugo.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
baseURL: "."
title: "R-Ladies Global"
theme: "hugo-rladies"
publishDir: "build"
publishDir: "public"

languageCode: "en"
defaultContentLanguage: "en"
Expand Down
5 changes: 3 additions & 2 deletions config/development/hugo.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
baseURL: "."
buildFuture: true
buildDrafts: true
build:
buildFuture: true
buildDrafts: true
5 changes: 3 additions & 2 deletions config/production/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ disableLanguages:
- "fr"
- "pt"
- "es"
buildFuture: false
buildDrafts: false
build:
buildFuture: false
buildDrafts: false
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading