deploy bookstack!
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 9s

This commit is contained in:
ThaMunsta
2025-03-15 13:16:23 -04:00
parent a814f60d17
commit 10389652c5
+27 -4
View File
@@ -7,7 +7,7 @@ jobs:
Explore-Gitea-Actions: Explore-Gitea-Actions:
runs-on: synology runs-on: synology
steps: steps:
- run: docker pull linuxserver/bookstack - run: docker pull linuxserver/bookstack #optional? probably faster if done first...
- name: Fetch stack ID from Portainer - name: Fetch stack ID from Portainer
run: | run: |
STACK_NAME="bookstack" STACK_NAME="bookstack"
@@ -16,14 +16,37 @@ jobs:
STACK_ID=$(curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks" | jq -r ".[] | select(.Name==\"$STACK_NAME\") | .Id") STACK_ID=$(curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks" | jq -r ".[] | select(.Name==\"$STACK_NAME\") | .Id")
echo "STACK_ID=$STACK_ID" >> $GITHUB_ENV echo "STACK_ID=$STACK_ID" >> $GITHUB_ENV
echo Got stack ID: $STACK_ID
- name: Trigger stack update in Portainer - name: Fetch stack configuration
run: | run: |
PORTAINER_API_URL="https://portainer.dev.nervesocket.com/api" PORTAINER_API_URL="https://portainer.dev.nervesocket.com/api"
PORTAINER_TOKEN="ptr_QkR9kDZuoC1QOwp+axwJPkK5av4NlmyjihS3JmTdPww=" PORTAINER_TOKEN="ptr_QkR9kDZuoC1QOwp+axwJPkK5av4NlmyjihS3JmTdPww="
curl -X POST "$PORTAINER_API_URL/stacks/$STACK_ID/redeploy" \ # Get the stack details (including stack file content)
curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks/$STACK_ID/file" \
| jq -r '.StackFileContent' > stack.yml
echo "Fetched stack configuration and saved it to stack.yml"
- name: Redeploy stack in Portainer
run: |
PORTAINER_API_URL="https://portainer.dev.nervesocket.com/api"
PORTAINER_TOKEN="ptr_QkR9kDZuoC1QOwp+axwJPkK5av4NlmyjihS3JmTdPww="
# 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}')
echo "About to push the following JSON payload:"
echo $JSON_PAYLOAD
# Update stack in Portainer (this redeploys it)
curl -X PUT "$PORTAINER_API_URL/stacks/$STACK_ID" \
-H "X-API-Key: $PORTAINER_TOKEN" \ -H "X-API-Key: $PORTAINER_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
--data '{"pullImage": true}' --data "$JSON_PAYLOAD"
- run: echo "🍏 This job's status is ${{ job.status }}." - run: echo "🍏 This job's status is ${{ job.status }}."