Files
caperren-com/.gitea/workflows/build.yaml
Corwin Perren cd397b1d15
Some checks failed
Build and Test / determine_version (push) Successful in 9s
Build and Test / build_and_push (push) Successful in 1m6s
Build and Test / test (push) Successful in 1s
Build and Test / deploy_production (push) Failing after 2s
Automated deployment
2025-03-31 15:28:57 -07:00

121 lines
4.6 KiB
YAML

name: Build and Test
on:
push:
branches: [main]
# pull_request:
# branches: [main]
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 }}
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:
runs-on: ubuntu-latest
needs: determine_version
steps:
- name: Checkout Obsidian Repo
uses: actions/checkout@v4
with:
repository: caperren/obsidian
token: ${{ secrets.ACTIONS_TOKEN }}
path: obsidian
- 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: Copy Website Obsidian Content
run: |
mv "${{ gitea.workspace }}/caperren-com/src/content/config.ts" "${{ gitea.workspace }}/caperren-com/src/config.ts"
rm -rf "${{ gitea.workspace }}/caperren-com/src/content"
mv "${{ gitea.workspace }}/obsidian/00002 - Projects/Websites/caperren-com" "${{ gitea.workspace }}/caperren-com/src/content"
mv "${{ gitea.workspace }}/caperren-com/src/config.ts" "${{ gitea.workspace }}/caperren-com/src/content/config.ts"
- 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:
runs-on: ubuntu-latest
needs: build_and_push
steps:
- run: echo "Placeholder"
# - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
# - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
# - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
# - name: Check out repository code
# uses: actions/checkout@v4
# - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
# - run: echo "🖥️ The workflow is now ready to test your code on the runner."
# - name: List files in the repository
# run: |
# ls ${{ gitea.workspace }}
# - run: echo "🍏 This job's status is ${{ job.status }}."
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": "caperren-com",
"options": {}
}'
- name: Stop App
run: |
curl -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"' \
|| true
- name: Stop Existing App
- name: Start App
run: |
curl -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"' \
|| true