Skip to content

STW: Move theme to main repo #29

STW: Move theme to main repo

STW: Move theme to main repo #29

name: PR Hugo Deploy
# see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
on:
pull_request:
# types: [labeled]
workflow_dispatch:
jobs:
build:
if: ${{ contains( github.event.pull_request.labels.*.name, 'deploy_pr') }}
# if: ${{ (github.event.label.name == 'deploy_pr') && (github.repository == 'htw-imi-showtime/showtime-website') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Get Theme
run: |
git submodule update --init themes/showtime-theme-2021
- name: Hugo setup
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.128.0'
extended: true
- name: Update Config
run: |
ls config/pull_request
cat config/pull_request/config.toml
sed -i "s/101/${{ github.event.number }}/g" config/pull_request/config.toml
echo "----- updated config: "
cat config/pull_request/config.toml
- name: Build
run: |
hugo \
--environment pull_request \
--baseURL "https://htw-imi-showtime.github.io/pull_request/${{ github.event.number }}/" \
--buildDrafts \
--destination hugo_generated_site/public
- name: "Upload artifact"
uses: actions/upload-artifact@v4
with:
name: hugo_site
path: hugo_generated_site
# see https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: "pr number"
run: |
echo ${{ github.event.number }}
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: hugo_site
path: hugo_generated_site
- name: Push to pull_request repo
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.PULL_REQUEST_DEPLOY_KEY }}
with:
source-directory: 'hugo_generated_site/public'
destination-github-username: 'htw-imi-showtime'
destination-repository-name: 'pull_request'
user-email: [email protected]
target-branch: gh-pages
target-directory: ${{ github.event.number }}
- name: show url
run: |
echo "after the pages build and deployment action https://github.com/htw-imi-showtime/pull_request/actions"
echo "available at https://htw-imi-showtime.github.io/pull_request/${{ github.event.number }}"
# https://cpina.github.io/push-to-another-repository-docs/
# https://github.com/htw-imi-showtime/pull_request