From 41986f55031e4df748b1196d90555d2a80489eff Mon Sep 17 00:00:00 2001 From: Mike Johnston Date: Tue, 23 Sep 2025 22:44:02 -0400 Subject: [PATCH] Create actual.yaml --- .gitea/workflows/actual.yaml | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .gitea/workflows/actual.yaml diff --git a/.gitea/workflows/actual.yaml b/.gitea/workflows/actual.yaml new file mode 100644 index 0000000..2f769f7 --- /dev/null +++ b/.gitea/workflows/actual.yaml @@ -0,0 +1,66 @@ +# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions +name: Pull Images and Redeploy +run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 +on: + workflow_dispatch: # Allows manual triggering + +env: + STACK_NAME: actual + PORTAINER_TOKEN: ${{ vars.PORTAINER_TOKEN }} #added as global variable + PORTAINER_API_URL: https://portainer.dev.nervesocket.com/api + ENDPOINT_NAME: "synology" #sometimes "primary" + +jobs: + Update-actual: + runs-on: ubuntu-latest + steps: + # if: contains(github.event.pull_request.head.ref, 'init-stack') + - name: Checkout + uses: actions/checkout@v4 + with: + ref: main + + - 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. + run: | + ENDPOINT_ID=$(curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/endpoints" | jq -r ".[] | select(.Name==\"$ENDPOINT_NAME\") | .Id") + echo "ENDPOINT_ID=$ENDPOINT_ID" >> $GITHUB_ENV + echo "Got stack Endpoint ID: $ENDPOINT_ID" + + - name: Fetch stack ID from Portainer + run: | + STACK_ID=$(curl -s -H "X-API-Key: $PORTAINER_TOKEN" "$PORTAINER_API_URL/stacks" | jq -r ".[] | select(.Name==\"$STACK_NAME\" and .EndpointId==$ENDPOINT_ID) | .Id") + + echo "STACK_ID=$STACK_ID" >> $GITHUB_ENV + echo "Got stack ID: $STACK_ID matched with Endpoint ID: $ENDPOINT_ID" + + - name: Fetch Stack + run: | + # 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 + + - name: Update stack in Portainer + run: | + # Read stack file content + STACK_FILE_CONTENT=$(echo "$(