Compare commits

...

5 Commits

Author SHA1 Message Date
ThaMunsta
1fe761be3f Merge branch 'dev' 2025-03-15 21:37:03 -04:00
ThaMunsta
1e07053fbe update 2025-03-15 21:36:50 -04:00
ThaMunsta
479568ebea test
Some checks failed
Gitea Actions Demo / Create-Stack (pull_request) Failing after 48s
2025-03-15 21:30:46 -04:00
7fd0218dd7 Merge branch 'main' into dev 2025-03-16 01:27:54 +00:00
ThaMunsta
feb1b09ad3 try again? 2025-03-15 21:26:45 -04:00
3 changed files with 148 additions and 5 deletions

View File

@@ -2,11 +2,12 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on:
pull_request:
push:
branches:
- 'stack-init'
paths:
- 'stack.yml'
tags:
- init-stack
jobs:
Create-Stack:
runs-on: synology
@@ -15,7 +16,7 @@ jobs:
- name: Checkout
uses: https://github.com/actions/checkout@v4
with:
ref: init-stack
ref: stack-init
- name: Get the endpoint ID
# Usually ID is 1, but you can get it from the API. Only skip this if you are VERY sure.

View File

@@ -0,0 +1,142 @@
name: TournamentCaddie Prod Deploy
on:
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker registry
uses: docker/login-action@v1
with:
registry: reg.dev.nervesocket.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} # This is a secret field, add your Docker Hub password here as a GitHub secret
- name: Build and push docker image
id: build
run: |
docker buildx build --tag reg.dev.nervesocket.com/tournamentcaddie:latest .
docker push reg.dev.nervesocket.com/tournamentcaddie:latest # This will tag and push the image to your Docker registry
- name: Update docker stack
run: |
docker pull reg.dev.nervesocket.com/tournamentcaddie:latest # This is just an example, you would need to replace this with the correct command for updating your docker stack
name: Deploy TournamentCaddie
on:
push:
branches:
- main
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to private registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login reg.dev.nervesocket.com -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Build and push Docker image
run: |
IMAGE_TAG="reg.dev.nervesocket.com/tournamentcaddie:latest"
docker build -t $IMAGE_TAG .
docker push $IMAGE_TAG
- name: Fetch stack ID from Portainer
run: |
STACK_NAME="TournamentCaddie"
PORTAINER_API_URL="http://portainer:9000/api"
PORTAINER_TOKEN="${{ secrets.PORTAINER_API_KEY }}"
STACK_ID=$(curl -s -H "Authorization: Bearer $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks" | jq -r ".[] | select(.Name==\"$STACK_NAME\") | .Id")
echo "STACK_ID=$STACK_ID" >> $GITHUB_ENV
- name: Trigger stack update in Portainer
run: |
PORTAINER_API_URL="http://portainer:9000/api"
PORTAINER_TOKEN="${{ secrets.PORTAINER_API_KEY }}"
curl -X POST "$PORTAINER_API_URL/stacks/$STACK_ID/redeploy" \
-H "Authorization: Bearer $PORTAINER_TOKEN" \
-H "Content-Type: application/json" \
--data '{"pullImage": true}'
name: Deploy TournamentCaddie
on:
push:
branches:
- main
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to private registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login reg.dev.nervesocket.com -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Build and push Docker image
run: |
IMAGE_TAG="reg.dev.nervesocket.com/tournamentcaddie:latest"
docker build -t $IMAGE_TAG .
docker push $IMAGE_TAG
- name: Fetch stack ID from Portainer
run: |
STACK_NAME="TournamentCaddie"
PORTAINER_API_URL="http://portainer:9000/api"
PORTAINER_TOKEN="${{ secrets.PORTAINER_API_KEY }}"
STACK_ID=$(curl -s -H "Authorization: Bearer $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks" | jq -r ".[] | select(.Name==\"$STACK_NAME\") | .Id")
if [ -z "$STACK_ID" ]; then
echo "Error: Stack ID not found!"
exit 1
fi
echo "STACK_ID=$STACK_ID" >> $GITHUB_ENV
- name: Fetch stack configuration
run: |
PORTAINER_API_URL="http://portainer:9000/api"
PORTAINER_TOKEN="${{ secrets.PORTAINER_API_KEY }}"
# Get the stack details (including stack file content)
curl -s -H "Authorization: Bearer $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks/$STACK_ID/file" \
| jq -r '.StackFileContent' > stack.yml
- name: Redeploy stack in Portainer
run: |
PORTAINER_API_URL="http://portainer:9000/api"
PORTAINER_TOKEN="${{ secrets.PORTAINER_API_KEY }}"
# Read stack file content
STACK_FILE_CONTENT=$(jq -Rs . < stack.yml)
# Prepare JSON payload
JSON_PAYLOAD=$(jq -n --arg stackFileContent "$STACK_FILE_CONTENT" --argjson pullImage true \
'{stackFileContent: $stackFileContent, pullImage: $pullImage}')
# Update stack in Portainer (this redeploys it)
curl -X PUT "$PORTAINER_API_URL/stacks/$STACK_ID" \
-H "Authorization: Bearer $PORTAINER_TOKEN" \
-H "Content-Type: application/json" \
--data "$JSON_PAYLOAD"

View File

@@ -8,4 +8,4 @@ services:
environment:
- TZ=America/Toronto
ports:
- 1118:80
- 1111:80