Skip to content
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
tmp
log
.git
.github
*.log
.env
dist
tests
8 changes: 4 additions & 4 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ on:
workflow_dispatch:
push:
branches:
- main
- master

jobs:
flow:
name: Highsoft Flow
uses: highsoft-corp/hs-platform-workflows/.github/workflows/flow_docker.yml@feat/multi-env-builds
uses: ./.github/workflows/flow_docker.yml
secrets: inherit
with:
registry: ghcr.io
folder_name: .
image_name: ${{ github.repository }}
use_image_per_environment: false
platforms: linux/amd64
platforms: linux/amd64
deploy_branch: master
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Build Docker Image

on:
workflow_call:
inputs:
version:
description: "The version number"
default: "1.0.0"
required: false
type: string
registry:
description: "The Docker Registry"
default: "ghcr.io"
required: false
type: string
image_name:
description: "The Docker image name"
default: ${{ github.repository }}
required: false
type: string
folder_name:
description: "The folder where the Dockerfile is located"
default: .
required: false
type: string
user_name:
description: "The name of the user to login to the registry"
default: ${{ github.actor }}
required: false
type: string
run_number:
description: "The workflow run number"
default: ${{ github.run_number }}
required: false
type: string
environment:
description: "The GitHub environment to use (for environment-specific secrets/variables)"
required: false
type: string
platforms:
description: "The platforms to build for"
required: false
type: string
default: linux/amd64,linux/arm64

outputs:
build_image:
description: "The build image"
value: ${{ jobs.build.outputs.build_image }}
build_image_tag:
description: "The build image tag"
value: ${{ jobs.build.outputs.build_image_tag }}
version:
description: "The new version number"
value: ${{ jobs.build.outputs.version }}

jobs:
build:
name: ${{ inputs.environment && format('Build {0} Image', inputs.environment) || 'Build Image' }}
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}

permissions:
contents: read
packages: write
attestations: write

outputs:
build_image: ${{ steps.output.outputs.build_image }}
build_image_tag: ${{ steps.output.outputs.build_image_tag }}
version: ${{ steps.output.outputs.version }}

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.user_name }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ inputs.registry }}/${{ inputs.image_name }}

- name: Build and publish image
id: push
uses: docker/build-push-action@v7.0.0
with:
context: ${{ inputs.folder_name }}
push: true
tags: ${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.version }}${{ inputs.environment && format('-{0}', inputs.environment) || '' }}-build.${{ inputs.run_number }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ inputs.platforms }}

- name: Store outputs
id: output
run: |
echo "build_image=${{ inputs.registry }}/${{ inputs.image_name }}" >> "$GITHUB_OUTPUT"
echo "build_image_tag=${{ inputs.version }}${{ inputs.environment && format('-{0}', inputs.environment) || '' }}-build.${{ inputs.run_number }}" >> "$GITHUB_OUTPUT"
echo "version=${{ inputs.version }}" >> "$GITHUB_OUTPUT"

- name: Generate summary
run: |
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY;
echo "Build Image: ${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.version }}${{ inputs.environment && format('-{0}', inputs.environment) || '' }}-build.${{ inputs.run_number }}" >> $GITHUB_STEP_SUMMARY;
74 changes: 74 additions & 0 deletions .github/workflows/docker_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Deploy Docker Image

on:
workflow_call:
inputs:
version:
description: "The version number"
required: true
type: string
registry:
description: "The Docker Registry"
default: "ghcr.io"
required: false
type: string
image_name:
description: "The Docker image name"
default: ${{ github.repository }}
required: false
type: string
build_image:
description: "The Docker Build Image (repository) to deploy"
required: true
type: string
build_image_tag:
description: "The Docker Build Image Tag to retag from"
required: true
type: string
deploy_tag:
description: "The target tag to deploy as"
required: true
type: string
environment:
description: "The GitHub environment to deploy to"
required: true
type: string
platforms:
description: "The platforms to deploy"
required: false
type: string
default: linux/amd64,linux/arm64

outputs:
image:
description: "The deployed image"
value: ${{ jobs.deploy.outputs.image }}

jobs:
deploy:
name: ${{ inputs.environment && format('Deploy {0} Image', inputs.environment) || 'Deploy Image' }}
runs-on: ubuntu-latest

environment: ${{ inputs.environment }}
permissions:
contents: read
packages: write
attestations: write

outputs:
image: ${{ steps.output.outputs.image }}

steps:
- name: Deploy to ${{ inputs.environment }}
uses: shrink/actions-docker-registry-tag@v4
with:
registry: ${{ inputs.registry }}
repository: ${{ inputs.build_image }}
target: ${{ inputs.build_image_tag }}
tags: |
${{ inputs.deploy_tag }}

- name: Store outputs
id: output
run: |
echo "image=${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.deploy_tag }}" >> "$GITHUB_OUTPUT"
2 changes: 1 addition & 1 deletion .github/workflows/eslint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
126 changes: 126 additions & 0 deletions .github/workflows/flow_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Build and Deploy Docker Image

on:
workflow_call:
inputs:
registry:
description: "The Docker Registry"
default: "ghcr.io"
required: false
type: string
image_name:
description: "The Docker image name"
default: ${{ github.repository }}
required: false
type: string
folder_name:
description: "The folder where the Dockerfile is located"
default: .
required: false
type: string
deploy_branch:
description: "The branch that will be deployed"
default: ${{ github.event.repository.default_branch }}
required: false
type: string
platforms:
description: "The platforms to build for"
required: false
type: string
default: linux/amd64
use_image_per_environment:
description: "Whether to create one image for each environment. Needed for statically generated webapps like NextJS"
default: false
required: false
type: boolean

jobs:
version:
name: Read Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Read version from VERSION file
id: version
working-directory: ${{ inputs.folder_name }}
run: |
VERSION=$(cat VERSION)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "## Version" >> $GITHUB_STEP_SUMMARY
echo "$VERSION" >> $GITHUB_STEP_SUMMARY

build:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Build Image
uses: ./.github/workflows/docker_build.yml
if: ${{ !inputs.use_image_per_environment }}
secrets: inherit
needs: version
with:
registry: ${{ inputs.registry }}
image_name: ${{ inputs.image_name }}
folder_name: ${{ inputs.folder_name }}
version: ${{ needs.version.outputs.version }}
run_number: ${{ github.run_number }}
user_name: ${{ github.actor }}
platforms: ${{ inputs.platforms }}

# Deploy to Development
deploy-dev:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
name: Deploy Development Image
uses: ./.github/workflows/docker_deploy.yml
secrets: inherit
if: ${{ !failure() && !cancelled() && github.ref_name == inputs.deploy_branch }}
needs:
- version
- build
with:
version: ${{ needs.version.outputs.version }}
registry: ${{ inputs.registry }}
image_name: ${{ inputs.image_name }}
build_image: ${{ needs.build.outputs.build_image }}
build_image_tag: ${{ needs.build.outputs.build_image_tag }}
deploy_tag: ${{ needs.version.outputs.version }}-dev
platforms: ${{ inputs.platforms }}
environment: development

# Deploy to Staging
deploy-staging:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
name: Deploy Staging Image
uses: ./.github/workflows/docker_deploy.yml
secrets: inherit
if: ${{ !failure() && !cancelled() && github.ref_name == inputs.deploy_branch }}
needs:
- version
- build
with:
version: ${{ needs.version.outputs.version }}
registry: ${{ inputs.registry }}
image_name: ${{ inputs.image_name }}
build_image: ${{ needs.build.outputs.build_image }}
build_image_tag: ${{ needs.build.outputs.build_image_tag }}
deploy_tag: ${{ needs.version.outputs.version }}-staging
environment: staging
platforms: ${{ inputs.platforms }}

# Deploy to Production
deploy-prod:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
name: Deploy Production Image
uses: ./.github/workflows/docker_deploy.yml
secrets: inherit
if: ${{ !failure() && !cancelled() && github.ref_name == inputs.deploy_branch }}
needs:
- version
- build
with:
version: ${{ needs.version.outputs.version }}
registry: ${{ inputs.registry }}
image_name: ${{ inputs.image_name }}
build_image: ${{ needs.build.outputs.build_image }}
build_image_tag: ${{ needs.build.outputs.build_image_tag }}
deploy_tag: ${{ needs.version.outputs.version }}
environment: production
platforms: ${{ inputs.platforms }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
14 changes: 14 additions & 0 deletions .versionrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"packageFiles": [
{
"filename": "VERSION",
"type": "plain-text"
}
],
"bumpFiles": [
{
"filename": "VERSION",
"type": "plain-text"
}
]
}
Loading
Loading