Skip to content

added hugo--build-release-deploy.yml #1

added hugo--build-release-deploy.yml

added hugo--build-release-deploy.yml #1

name: Hugo Build, Release, and Deploy Reusable Workflow

Check failure on line 1 in .github/workflows/hugo--build-release-deploy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/hugo--build-release-deploy.yml

Invalid workflow file

`env` is not a valid event name
on:
workflow_call:
inputs:
# GitHub Input Vars
github-run-id:
description: ''
default: ''
required: false
type: string
github-workflow:
description: ''
default: ''
required: false
type: string
github-workflow-ref:
description: ''
default: ''
required: false
type: string
github-workflow-sha:
description: ''
default: ''
required: false
type: string
github-workspace:
description: ''
default: ''
required: false
type: string
github-repository:
description: ''
default: ''
required: false
type: string
github-repository-owner:
description: ''
default: ''
required: false
type: string
github-repository-name:
description: ''
default: ''
required: false
type: string
github-repository-url:
description: ''
default: ''
required: false
type: string
github-action-ref:
description: ''
default: ''
required: false
type: string
github-event-name:
description: ''
default: ''
required: false
type: string
github-actor:
description: ''
default: ''
required: false
type: string
github-triggering-actor:
description: ''
default: ''
required: false
type: string
github-base-ref:
description: ''
default: ''
required: false
type: string
github-ref-name:
description: ''
default: ''
required: false
type: string
github-ref-type:
description: ''
default: ''
required: false
type: string
github-ref:
description: ''
default: ''
required: false
type: string
github-sha:
description: ''
default: ''
required: false
type: string
# Build Input Vars
container-registry: # container registry e.g. ghcr.io
required: true
type: string
container-image-name: # name of container image i.e. github package
required: true
type: string
hugo-context-root: # root path for hugo build
required: true
type: string
hugo-devl-url: # hugo development url
required: true
type: string
hugo-prod-url: # hugo production url
required: true
type: string
#REGISTRY: ghcr.io
#IMAGE_NAME: "ghcr.io/${{ github.repository }}-website"
#CONTEXT_ROOT: "bom-website"
#DEVL_URL: "https://dev.deathbynumbers.org/"
#PROD_URL: "https://deathbynumbers.org/"
# Release Input Vars
build-artifact-name: # name of build artifact to transfer between jobs/workflows
required: true
type: string
release-tag-name-type: # semvar | iso
required: true
type: string
env:
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
username: ${{ inputs.github-repository-owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ inputs.container-registry }}
- name: Build and Push Docker Image for Local Dev
uses: docker/build-push-action@v4
with:
context: "${{ inputs.hugo-context-root }}"
push: true
tags: "${{ inputs.container-image-name }}:latest"
platforms: linux/amd64
- name: Build Docker Image (devl)
if: inputs.github-ref == 'refs/heads/preview'
uses: docker/build-push-action@v4
with:
context: "${{ inputs.hugo-context-root }}"
push: false
tags: "${{ inputs.container-image-name }}:latest"
platforms: linux/amd64
build-args: |
hugobuildargs=--cleanDestinationDir --buildDrafts --buildFuture --baseURL ${{ inputs.hugo-devl-url }}
- name: Build Docker Image (prod)
if: inputs.github-ref == 'refs/heads/main'
uses: docker/build-push-action@v4
with:
context: "${{ inputs.hugo-context-root }}"
push: false
tags: "${{ inputs.container-image-name }}:latest"
platforms: linux/amd64
build-args: |
hugobuildargs=--cleanDestinationDir --minify --baseURL ${{ inputs.hugo-prod-url }}
- name: Extract build artifact from docker image
uses: shrink/actions-docker-extract@v2
id: extract
with:
image: "${{ inputs.container-image-name }}:latest"
path: /usr/share/nginx/html/
- name: Archive build artifact
run: tar czvf ${{ inputs.build-artifact-name }}.tar.gz -C ${{ steps.extract.outputs.destination }}/html .
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
path: "./${{ inputs.build-artifact-name }}.tar.gz"
name: "${{ inputs.build-artifact-name }}"