fix: streamline deployment process by removing Gitea registry login steps and enhancing Portainer API integration
Some checks failed
Build And Publish Production Image / Build And Publish Production Image (push) Failing after 16s
Some checks failed
Build And Publish Production Image / Build And Publish Production Image (push) Failing after 16s
This commit is contained in:
@@ -34,24 +34,38 @@ jobs:
|
|||||||
docker tag condado-newsletter:latest ${REGISTRY}/${IMAGE_NAME}:latest
|
docker tag condado-newsletter:latest ${REGISTRY}/${IMAGE_NAME}:latest
|
||||||
docker tag condado-newsletter:latest ${REGISTRY}/${IMAGE_NAME}:${{ github.sha }}
|
docker tag condado-newsletter:latest ${REGISTRY}/${IMAGE_NAME}:${{ github.sha }}
|
||||||
|
|
||||||
|
- name: Deploy stack via Portainer API
|
||||||
|
env:
|
||||||
|
STACK_NAME: condado-newsletter
|
||||||
|
PORTAINER_URL: http://portainer.lab
|
||||||
|
PORTAINER_API_KEY: ${{ secrets.PORTAINER_API_KEY }}
|
||||||
|
PORTAINER_ENDPOINT_ID: ${{ secrets.PORTAINER_ENDPOINT_ID }}
|
||||||
|
run: |
|
||||||
|
STACK_ID=$(curl -sf \
|
||||||
|
"${PORTAINER_URL}/api/stacks" \
|
||||||
|
-H "X-API-Key: ${PORTAINER_API_KEY}" \
|
||||||
|
| jq -r --arg stack_name "$STACK_NAME" '.[] | select(.Name == $stack_name) | .Id' \
|
||||||
|
| head -n 1)
|
||||||
|
|
||||||
# - name: Log in to Gitea container registry
|
if [ -n "$STACK_ID" ]; then
|
||||||
# run: |
|
PAYLOAD=$(jq -n \
|
||||||
# if [ -z "$REGISTRY_USERNAME" ]; then
|
--rawfile stack_file docker-compose.prod.yml \
|
||||||
# REGISTRY_USERNAME="${{ github.actor }}"
|
'{StackFileContent: $stack_file, Env: [], Prune: false, PullImage: false}')
|
||||||
# echo "REGISTRY_USERNAME secret is empty; falling back to github.actor: $REGISTRY_USERNAME"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# if [ -z "$REGISTRY_PASSWORD" ]; then
|
curl -sf -X PUT \
|
||||||
# echo "REGISTRY_PASSWORD secret is empty; cannot log in to ${REGISTRY}."
|
"${PORTAINER_URL}/api/stacks/${STACK_ID}?endpointId=${PORTAINER_ENDPOINT_ID}" \
|
||||||
# exit 1
|
-H "X-API-Key: ${PORTAINER_API_KEY}" \
|
||||||
# fi
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$PAYLOAD"
|
||||||
|
else
|
||||||
|
PAYLOAD=$(jq -n \
|
||||||
|
--arg name "$STACK_NAME" \
|
||||||
|
--rawfile stack_file docker-compose.prod.yml \
|
||||||
|
'{Name: $name, StackFileContent: $stack_file, Env: [], FromAppTemplate: false}')
|
||||||
|
|
||||||
# echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" -u "$REGISTRY_USERNAME" --password-stdin
|
curl -sf -X POST \
|
||||||
|
"${PORTAINER_URL}/api/stacks/create/standalone/string?endpointId=${PORTAINER_ENDPOINT_ID}" \
|
||||||
# - name: Tag and push registry images
|
-H "X-API-Key: ${PORTAINER_API_KEY}" \
|
||||||
# run: |
|
-H "Content-Type: application/json" \
|
||||||
# docker tag condado-newsletter:latest ${REGISTRY}/${IMAGE_NAME}:latest
|
-d "$PAYLOAD"
|
||||||
# docker tag condado-newsletter:latest ${REGISTRY}/${IMAGE_NAME}:${{ github.sha }}
|
fi
|
||||||
# docker push ${REGISTRY}/${IMAGE_NAME}:latest
|
|
||||||
# docker push ${REGISTRY}/${IMAGE_NAME}:${{ github.sha }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user