From a3d19d0e0253797cc09d0701e015f39a9e3d32d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:22:32 +0200 Subject: [PATCH] add deploy step with some temporary code --- .github/workflows/ci.yml | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db545c35..c9e19bb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -163,3 +163,53 @@ jobs: --target dist \ --push \ ./ + + deploy: + runs-on: ubuntu-latest + needs: [unit_tests, isort, black, flake8, mypy] + if: | + github.event_name == 'push' && + ( + github.ref == 'refs/heads/ci' || + github.ref == 'refs/heads/develop' || + github.ref == 'refs/heads/staging' || + github.ref == 'refs/heads/master' + ) + steps: + - name: Trigger deploy + run: | + if [ ${{ github.ref }} == 'refs/heads/develop' ]; then + pipelineId=TODO + elif [ ${{ github.ref }} == 'refs/heads/staging' ]; then + pipelineId=TODO + elif [ ${{ github.ref }} == 'refs/heads/master' ]; then + pipelineId=TODO + elif [ ${{ github.ref }} == 'refs/heads/ci' ]; then + pipelineId=WIP + else + echo "No pipeline to trigger for ref ${{ github.ref }}" + exit 0 + fi + + IFS=',' read -ra pipelines <<< "$pipelineId" + for pipeline in "${pipelines[@]}"; do + jsonBody='{"variables": {"sha": {"isSecret": false, "value": "${{ github.sha }}"}, "tag": {"isSecret": false, "value": "flex-registration-${{ github.sha }}"}}}' + contentLength=$(echo -n $jsonBody | wc -c) + project=ICTD-HCT-MIS + organization=unicef + + echo Triggering deploy for pipeline $pipeline + echo JSON body: $jsonBody + + curl -f -v -L \ + -u ":${{ secrets.AZURE_PAT }}" \ + -H "Content-Type: application/json" \ + -H "Content-Length: $contentLength" \ + -d "$jsonBody" \ + https://dev.azure.com/$organization/$project/_apis/pipelines/$pipeline/runs?api-version=7.1-preview.1 + if [ $? -ne 0 ]; then + echo "Failed to trigger deploy for pipeline $pipeline" + exit 1 + fi + done +