Skip to content

CD Deployment

CD Deployment #5

Workflow file for this run

name: "CD Deployment"
on:
workflow_run:
workflows: ["CD Build"]
types:
- completed
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Decode Registry credentials
id: auth
run: |
AUTH_CONFIG=$(echo -n "{\"username\":\"${{ github.actor }}\",\"password\":\"${{ secrets.GITHUB_TOKEN }}\",\"serveraddress\":\"ghcr.io\"}" | base64)
echo "auth=$AUTH_CONFIG" >> $GITHUB_OUTPUT
- name: Get current service version
id: get_version
run: |
SERVICE_VERSION=$(curl -s -X GET "${{ vars.BASE_URLE }}${{ vars.SERVICE_NAME }}" \
-H "x-api-key: ${{ secrets.API_KEY }}" \
-H "Content-Type: application/json" | jq -r '.Version.Index')
echo "version=$SERVICE_VERSION" >> $GITHUB_OUTPUT
- name: Create deployment payload
id: create_payload
run: |
cat <<EOF > deployment_payload.json
{
"Name": "backend-service-dev",
"TaskTemplate": {
"ContainerSpec": {
"Image": "ghcr.io/remsfal/remsfal-backend:latest"
}
}
}
EOF
- name: Update Docker service
run: |
curl -v -X POST "${{ vars.BASE_URLE }}${{ vars.SERVICE_NAME }}/update?version=${{ steps.get_version.outputs.version }}&rollback=previous" \
-H "x-api-key: ${{ secrets.API_KEY }}" \
-H "Content-Type: application/json" \
-H "X-Registry-Auth: ${{ steps.auth.outputs.auth }}" \
-d @deployment_payload.json