now we are cookin!
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 8s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 8s
This commit is contained in:
@@ -12,16 +12,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
STACK_NAME="bookstack"
|
STACK_NAME="bookstack"
|
||||||
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="${{ secrets.PORTAINER_API_KEY }}"
|
||||||
|
|
||||||
STACK_ID=$(curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks" | jq -r ".[] | select(.Name==\"$STACK_NAME\") | .Id")
|
STACK_DATA=$(curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks" | jq -r ".[] | select(.Name==\"$STACK_NAME\") | {Id, EndpointId}")
|
||||||
|
|
||||||
|
STACK_ID=$(echo "$STACK_DATA" | jq -r ".Id")
|
||||||
|
ENDPOINT_ID=$(echo "$STACK_DATA" | jq -r ".EndpointId")
|
||||||
echo "STACK_ID=$STACK_ID" >> $GITHUB_ENV
|
echo "STACK_ID=$STACK_ID" >> $GITHUB_ENV
|
||||||
echo Got stack ID: $STACK_ID
|
echo "ENDPOINT_ID=$ENDPOINT_ID" >> $GITHUB_ENV
|
||||||
|
echo "Got stack ID: $STACK_ID and Endpoint ID: $ENDPOINT_ID"
|
||||||
|
|
||||||
- name: Fetch stack configuration
|
- 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="${{ secrets.PORTAINER_API_KEY }}"
|
||||||
|
|
||||||
# Get the stack details (including stack file content)
|
# Get the stack details (including stack file content)
|
||||||
curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks/$STACK_ID/file" \
|
curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks/$STACK_ID/file" \
|
||||||
@@ -32,7 +36,7 @@ jobs:
|
|||||||
- name: Redeploy stack in Portainer
|
- name: Redeploy stack in Portainer
|
||||||
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="${{ secrets.PORTAINER_API_KEY }}"
|
||||||
|
|
||||||
# Read stack file content
|
# Read stack file content
|
||||||
STACK_FILE_CONTENT=$(jq -Rs . < stack.yml)
|
STACK_FILE_CONTENT=$(jq -Rs . < stack.yml)
|
||||||
@@ -45,12 +49,12 @@ jobs:
|
|||||||
echo $JSON_PAYLOAD
|
echo $JSON_PAYLOAD
|
||||||
|
|
||||||
# Update stack in Portainer (this redeploys it)
|
# Update stack in Portainer (this redeploys it)
|
||||||
DEPLOY_RESPONSE=$(curl -X PUT "$PORTAINER_API_URL/stacks/$STACK_ID" \
|
DEPLOY_RESPONSE=$(curl -X PUT "$PORTAINER_API_URL/stacks/$STACK_ID?endpointId=$ENDPOINT_ID" \
|
||||||
-H "X-API-Key: $PORTAINER_TOKEN" \
|
-H "X-API-Key: $PORTAINER_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "$JSON_PAYLOAD")
|
--data "$JSON_PAYLOAD")
|
||||||
|
|
||||||
echo "Redeployed stack in Portainer. Response:"
|
echo "Redeployed stack in Portainer. Response:"
|
||||||
echo $DEPLOY_RESPONSE
|
echo $DEPLOY_RESPONSE
|
||||||
|
|
||||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
Reference in New Issue
Block a user