From b219b9d62b5d7598fd7d129ad780d41b967fbbce Mon Sep 17 00:00:00 2001 From: Jeremy McCormick Date: Mon, 26 Feb 2024 14:41:41 -0600 Subject: [PATCH 1/6] Add initial implementation of build and deployment workflow --- .github/workflows/build_and_deploy.yaml | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/build_and_deploy.yaml diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml new file mode 100644 index 0000000..b95152b --- /dev/null +++ b/.github/workflows/build_and_deploy.yaml @@ -0,0 +1,35 @@ +name: "Build and deploy the website" + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +env: + HUGO_VERSION: 0.123.4 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download hugo + run: | + wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz + tar -zxvf hugo_${HUGO_VERSION}_Linux-64bit.tar.gz hugo + + - name: Build the website + run: ./hugo + + - name: Deploy the website + uses: Dylan700/sftp-upload-action@latest + with: + username: webstage + host: web.ivoa.net + uploads: | + ./public/ => ./ivoa-web-stage/ + if: github.event_name != 'pull_request' From 51088977d7ac25f40de78fedcc573bc4bca51df1 Mon Sep 17 00:00:00 2001 From: Jeremy McCormick Date: Mon, 26 Feb 2024 14:41:52 -0600 Subject: [PATCH 2/6] Ignore hugo-related files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index de287e8..8530fc1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ hugo_stats.json # tmp hugo file .hugo_build.lock + +# ignore hugo in case you have installed it in the project directory +hugo +hugo*.tar.gz From bbd0bf05e2f0ee3c683a408d04c2a9a832a07777 Mon Sep 17 00:00:00 2001 From: Jeremy McCormick Date: Mon, 26 Feb 2024 14:49:00 -0600 Subject: [PATCH 3/6] Set a variable for dry run of deployment If the action is running as part of a PR check, the deployment will be a dry run. --- .github/workflows/build_and_deploy.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index b95152b..521bdee 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -25,11 +25,14 @@ jobs: - name: Build the website run: ./hugo + - name: Set dry run + run: echo "DRY_RUN=${{ github.event_name == 'pull_request' && 'true' || 'false' }}" >> $GITHUB_ENV + - name: Deploy the website uses: Dylan700/sftp-upload-action@latest with: username: webstage host: web.ivoa.net + dry-run: ${{ env.DRY_RUN }} uploads: | ./public/ => ./ivoa-web-stage/ - if: github.event_name != 'pull_request' From 5bdc4f6883466d5b62a20f90d8a873353d8b1954 Mon Sep 17 00:00:00 2001 From: Jeremy McCormick Date: Mon, 26 Feb 2024 14:54:52 -0600 Subject: [PATCH 4/6] Correct parameter name for server --- .github/workflows/build_and_deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index 521bdee..f880a3b 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -32,7 +32,7 @@ jobs: uses: Dylan700/sftp-upload-action@latest with: username: webstage - host: web.ivoa.net + server: web.ivoa.net dry-run: ${{ env.DRY_RUN }} uploads: | ./public/ => ./ivoa-web-stage/ From 834849facb2729288bb044a1eb90a6d96dd85c46 Mon Sep 17 00:00:00 2001 From: Jeremy McCormick Date: Mon, 26 Feb 2024 14:57:24 -0600 Subject: [PATCH 5/6] Add stage key --- .github/workflows/build_and_deploy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index f880a3b..4903bf0 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -34,5 +34,6 @@ jobs: username: webstage server: web.ivoa.net dry-run: ${{ env.DRY_RUN }} + key: ${{ secrets.STAGE_ID }} uploads: | ./public/ => ./ivoa-web-stage/ From 6679d2c49b5bf7d9f958886089e66841e8bc7bc3 Mon Sep 17 00:00:00 2001 From: Jeremy McCormick Date: Tue, 5 Mar 2024 14:23:52 -0600 Subject: [PATCH 6/6] Minor change to root-level hugo file patterns that should be ignored --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8530fc1..8bd7f63 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,5 @@ hugo_stats.json .hugo_build.lock # ignore hugo in case you have installed it in the project directory -hugo -hugo*.tar.gz +/hugo +/hugo*.tar.gz