Commonize builds, add staging build
All checks were successful
Build and Test Staging / build_test_deploy (pull_request) Has been skipped
All checks were successful
Build and Test Staging / build_test_deploy (pull_request) Has been skipped
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
name: Build and Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_call:
|
||||
inputs:
|
||||
build_environment:
|
||||
description: "The build environment (e.g., staging, production)"
|
||||
required: false
|
||||
default: "development"
|
||||
|
||||
jobs:
|
||||
determine_version:
|
||||
@@ -10,6 +15,8 @@ jobs:
|
||||
repo_name: ${{ steps.project_metadata.outputs.REPO_NAME }}
|
||||
repo_version_hash: ${{ steps.project_metadata.outputs.REPO_VERSION_HASH }}
|
||||
project_version: ${{ steps.project_metadata.outputs.PROJECT_VERSION }}
|
||||
docker_tags: ${{ steps.generate_docker_tags.outputs.DOCKER_TAGS }}
|
||||
docker_deploy_target: ${{ steps.generate_docker_deployment_target.outputs.DOCKER_DEPLOY_TARGET }}
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -24,6 +31,32 @@ jobs:
|
||||
echo REPO_VERSION_HASH=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
echo PROJECT_VERSION=$(npm pkg get version --workspaces=false | tr -d \") >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate Docker Tags
|
||||
id: generate_docker_tags
|
||||
run: |
|
||||
DOCKER_TAGS=""
|
||||
|
||||
if [ "${{ inputs.build_environment }}" = "staging" ]; then
|
||||
DOCKER_TAGS=("gitea.perren.cloud/caperren/caperren-com:latest-staging")
|
||||
else
|
||||
DOCKER_TAGS=("gitea.perren.cloud/caperren/caperren-com:${{ steps.project_metadata.outputs.REPO_VERSION_HASH }},")
|
||||
DOCKER_TAGS+=("gitea.perren.cloud/caperren/caperren-com:${{ steps.project_metadata.outputs.PROJECT_VERSION }},")
|
||||
DOCKER_TAGS+=("gitea.perren.cloud/caperren/caperren-com:latest")
|
||||
fi
|
||||
|
||||
echo DOCKER_TAGS >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate Docker Deployment Target
|
||||
id: generate_docker_deployment_target
|
||||
run: |
|
||||
if [ "${{ inputs.build_environment }}" = "staging" ]; then
|
||||
DOCKER_DEPLOY_TARGET=caperren-com-staging
|
||||
else
|
||||
DOCKER_DEPLOY_TARGET="caperren-com"
|
||||
fi
|
||||
|
||||
echo $DOCKER_DEPLOY_TARGET >> $GITHUB_OUTPUT
|
||||
|
||||
build_and_push:
|
||||
runs-on: ubuntu-latest
|
||||
needs: determine_version
|
||||
@@ -48,10 +81,7 @@ jobs:
|
||||
with:
|
||||
context: caperren-com
|
||||
push: true
|
||||
tags: |
|
||||
gitea.perren.cloud/caperren/${{ needs.determine_version.outputs.repo_name }}:${{ needs.determine_version.outputs.repo_version_hash }}
|
||||
gitea.perren.cloud/caperren/${{ needs.determine_version.outputs.repo_name }}:${{ needs.determine_version.outputs.project_version }}
|
||||
gitea.perren.cloud/caperren/caperren-com:latest
|
||||
tags: ${{ needs.determine_version.outputs.docker_tags }}
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -71,7 +101,7 @@ jobs:
|
||||
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"name": "caperren-com",
|
||||
"name": "${{ needs.determine_version.outputs.docker_deploy_target }}",
|
||||
"options": {}
|
||||
}'
|
||||
- name: Stop App
|
||||
@@ -81,7 +111,7 @@ jobs:
|
||||
-H 'accept: */*' \
|
||||
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '"caperren-com"'
|
||||
-d '"${{ needs.determine_version.outputs.docker_deploy_target }}"'
|
||||
- name: Start App
|
||||
run: |
|
||||
curl -k -X 'POST' \
|
||||
@@ -89,4 +119,4 @@ jobs:
|
||||
-H 'accept: */*' \
|
||||
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '"caperren-com"'
|
||||
-d '"${{ needs.determine_version.outputs.docker_deploy_target }}"'
|
||||
10
.gitea/workflows/build-production.yaml
Normal file
10
.gitea/workflows/build-production.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
name: Build and Test Production
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build_test_deploy:
|
||||
uses: ./.gitea/workflows/build-common.yaml
|
||||
with:
|
||||
build_environment: production
|
||||
10
.gitea/workflows/build-staging.yaml
Normal file
10
.gitea/workflows/build-staging.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
name: Build and Test Staging
|
||||
on:
|
||||
pull_request:
|
||||
types: [ opened, synchronize, reopened ]
|
||||
|
||||
jobs:
|
||||
build_test_deploy:
|
||||
uses: ./.gitea/workflows/build-common.yaml
|
||||
with:
|
||||
build_environment: staging
|
||||
Reference in New Issue
Block a user