Commonize builds, add staging build #3
@@ -1,124 +0,0 @@
|
|||||||
name: Build and Test
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
build_environment:
|
|
||||||
description: "The build environment (e.g., staging, production)"
|
|
||||||
required: false
|
|
||||||
default: "development"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
determine_version:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
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
|
|
||||||
|
|
||||||
- name: Setup Node Environment
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
|
|
||||||
- name: Acquire Project Metadata
|
|
||||||
id: project_metadata
|
|
||||||
run: |
|
|
||||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
|
||||||
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=$DOCKER_TAGS >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Generate Docker Deployment Target
|
|
||||||
id: generate_docker_deployment_target
|
|
||||||
run: |
|
|
||||||
DOCKER_DEPLOY_TARGET=""
|
|
||||||
|
|
||||||
if [ "${{ inputs.build_environment }}" = "staging" ]; then
|
|
||||||
DOCKER_DEPLOY_TARGET=caperren-com-staging
|
|
||||||
else
|
|
||||||
DOCKER_DEPLOY_TARGET="caperren-com"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo DOCKER_DEPLOY_TARGET=$DOCKER_DEPLOY_TARGET >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
build_and_push:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: determine_version
|
|
||||||
steps:
|
|
||||||
- name: Checkout caperren-com Repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
path: caperren-com
|
|
||||||
|
|
||||||
- name: Login to Docker Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: gitea.perren.cloud
|
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
password: ${{ secrets.ACTIONS_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build and Push
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: caperren-com
|
|
||||||
push: true
|
|
||||||
tags: ${{ needs.determine_version.outputs.docker_tags }}
|
|
||||||
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build_and_push
|
|
||||||
steps:
|
|
||||||
- run: echo "Placeholder"
|
|
||||||
|
|
||||||
deploy_production:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: test
|
|
||||||
steps:
|
|
||||||
- name: Pull New Image For App
|
|
||||||
run: |
|
|
||||||
curl -k -X 'POST' \
|
|
||||||
'https://caperren.com:444/api/v2.0/app/pull_images' \
|
|
||||||
-H 'accept: */*' \
|
|
||||||
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"name": "${{ needs.determine_version.outputs.docker_deploy_target }}",
|
|
||||||
"options": {}
|
|
||||||
}'
|
|
||||||
- name: Stop App
|
|
||||||
run: |
|
|
||||||
curl -k -X 'POST' \
|
|
||||||
'https://caperren.com:444/api/v2.0/app/stop' \
|
|
||||||
-H 'accept: */*' \
|
|
||||||
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '"${{ needs.determine_version.outputs.docker_deploy_target }}"'
|
|
||||||
- name: Start App
|
|
||||||
run: |
|
|
||||||
curl -k -X 'POST' \
|
|
||||||
'https://caperren.com:444/api/v2.0/app/stop' \
|
|
||||||
-H 'accept: */*' \
|
|
||||||
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '"${{ needs.determine_version.outputs.docker_deploy_target }}"'
|
|
||||||
@@ -1,19 +1,92 @@
|
|||||||
name: Build and Test Production
|
name: Build and Test - Production
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
determine_version:
|
determine_version:
|
||||||
uses: ./.gitea/workflows/build-common.yaml
|
runs-on: ubuntu-latest
|
||||||
with:
|
outputs:
|
||||||
build_environment: production
|
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 }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node Environment
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
|
||||||
|
- name: Acquire Project Metadata
|
||||||
|
id: project_metadata
|
||||||
|
run: |
|
||||||
|
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
||||||
|
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
|
||||||
|
|
||||||
build_and_push:
|
build_and_push:
|
||||||
uses: ./.gitea/workflows/build-common.yaml
|
runs-on: ubuntu-latest
|
||||||
|
needs: determine_version
|
||||||
|
steps:
|
||||||
|
- name: Checkout caperren-com Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: caperren-com
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.perren.cloud
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.ACTIONS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and Push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
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
|
||||||
|
|
||||||
test:
|
test:
|
||||||
uses: ./.gitea/workflows/build-common.yaml
|
runs-on: ubuntu-latest
|
||||||
|
needs: build_and_push
|
||||||
|
steps:
|
||||||
|
- run: echo "Placeholder"
|
||||||
|
|
||||||
deploy_production:
|
deploy_production:
|
||||||
uses: ./.gitea/workflows/build-common.yaml
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
steps:
|
||||||
|
- name: Pull New Image For App
|
||||||
|
run: |
|
||||||
|
curl -k -X 'POST' \
|
||||||
|
'https://caperren.com:444/api/v2.0/app/pull_images' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"name": "caperren-com",
|
||||||
|
"options": {}
|
||||||
|
}'
|
||||||
|
- name: Stop App
|
||||||
|
run: |
|
||||||
|
curl -k -X 'POST' \
|
||||||
|
'https://caperren.com:444/api/v2.0/app/stop' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '"caperren-com"'
|
||||||
|
- name: Start App
|
||||||
|
run: |
|
||||||
|
curl -k -X 'POST' \
|
||||||
|
'https://caperren.com:444/api/v2.0/app/stop' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '"caperren-com"'
|
||||||
@@ -1,19 +1,90 @@
|
|||||||
name: Build and Test Staging
|
name: Build and Test - Staging
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [ opened, synchronize, reopened ]
|
types: [ opened, synchronize, reopened ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
determine_version:
|
determine_version:
|
||||||
uses: ./.gitea/workflows/build-common.yaml
|
runs-on: ubuntu-latest
|
||||||
with:
|
outputs:
|
||||||
build_environment: staging
|
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 }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node Environment
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
|
||||||
|
- name: Acquire Project Metadata
|
||||||
|
id: project_metadata
|
||||||
|
run: |
|
||||||
|
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
||||||
|
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
|
||||||
|
|
||||||
build_and_push:
|
build_and_push:
|
||||||
uses: ./.gitea/workflows/build-common.yaml
|
runs-on: ubuntu-latest
|
||||||
|
needs: determine_version
|
||||||
|
steps:
|
||||||
|
- name: Checkout caperren-com Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: caperren-com
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.perren.cloud
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.ACTIONS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and Push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: caperren-com
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
gitea.perren.cloud/caperren/caperren-com:latest-staging
|
||||||
|
|
||||||
test:
|
test:
|
||||||
uses: ./.gitea/workflows/build-common.yaml
|
runs-on: ubuntu-latest
|
||||||
|
needs: build_and_push
|
||||||
|
steps:
|
||||||
|
- run: echo "Placeholder"
|
||||||
|
|
||||||
deploy_production:
|
deploy_staging:
|
||||||
uses: ./.gitea/workflows/build-common.yaml
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
steps:
|
||||||
|
- name: Pull New Image For App
|
||||||
|
run: |
|
||||||
|
curl -k -X 'POST' \
|
||||||
|
'https://caperren.com:444/api/v2.0/app/pull_images' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"name": "caperren-com-staging",
|
||||||
|
"options": {}
|
||||||
|
}'
|
||||||
|
- name: Stop App
|
||||||
|
run: |
|
||||||
|
curl -k -X 'POST' \
|
||||||
|
'https://caperren.com:444/api/v2.0/app/stop' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '"caperren-com-staging"'
|
||||||
|
- name: Start App
|
||||||
|
run: |
|
||||||
|
curl -k -X 'POST' \
|
||||||
|
'https://caperren.com:444/api/v2.0/app/stop' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '"caperren-com-staging"'
|
||||||
Reference in New Issue
Block a user