adding workflows
This commit is contained in:
60
.gitea/workflows/immich.yaml
Normal file
60
.gitea/workflows/immich.yaml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# 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: immich
|
||||||
|
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-immich:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# if: contains(github.event.pull_request.head.ref, 'init-stack')
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: stage
|
||||||
|
|
||||||
|
- 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: Update stack in Portainer
|
||||||
|
run: |
|
||||||
|
# Read stack file content
|
||||||
|
STACK_FILE_CONTENT=$(echo "$(<stage-compose.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)
|
||||||
|
DEPLOY_RESPONSE=$(curl -X PUT "$PORTAINER_API_URL/stacks/$STACK_ID?endpointId=$ENDPOINT_ID" \
|
||||||
|
-H "X-API-Key: $PORTAINER_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
--data "$JSON_PAYLOAD")
|
||||||
|
|
||||||
|
echo "Redeployed stack in Portainer. Response:"
|
||||||
|
echo $DEPLOY_RESPONSE
|
||||||
|
|
||||||
|
- name: Status check
|
||||||
|
run: |
|
||||||
|
echo "📋 This job's status is ${{ job.status }}."
|
||||||
Reference in New Issue
Block a user