Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVOP-53 automatically deploy main branch to devNet #975

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 90 additions & 1 deletion .github/workflows/build-push-containers-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -975,4 +975,93 @@ jobs:
run: |
./scripts/movement/manifest helios


deploy-trigger:
if: github.event.label.name == 'cicd:movement-containers' || github.ref == 'refs/heads/main'
needs: [container-checks]
name: Trigger devNet deployment
runs-on: ubuntu-latest
outputs:
run_id: ${{ steps.get_run_id.outputs.run_id }}
run_url: ${{ steps.get_run_id.outputs.run_url }}
run_name: ${{ steps.get_run_id.outputs.run_name }}
steps:
- name: Dispatch Workflow
id: deploy
uses: benc-uk/workflow-dispatch@v1
with:
ref: main
token: ${{ secrets.INFRA_GH_TOKEN }}
repo: movement-infra/cdktf-mvmt-networks
workflow: environment-deploy.yml
inputs: '{"environment":"devNet","containerTag":"${{ github.sha }}"}'
- name: Retrieve workflow run ID of the deployment
env:
OWNER: movement-infra
REPO: cdktf-mvmt-networks
WORKFLOW_ID: ${{ steps.deploy.outputs.workflowId }}
BRANCH: main
id: get_run_id
run: |
API_URL="https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/runs?branch=${BRANCH}&status=in_progress&per_page=1"
sleep 30
run_data=$(curl -sSL -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.INFRA_GH_TOKEN }}" \
"$API_URL")
run_name=$(echo "$run_data" | jq -r '.workflow_runs[0].name')
run_id=$(echo "$run_data" | jq -r '.workflow_runs[0].id')
run_url=$(echo "$run_data" | jq -r '.workflow_runs[0].html_url')

echo "Workflow Run Info"
echo "NAME: $run_name"
echo "ID: $run_id"
echo "URL: $run_url"

# Setting the output for other steps in the same job
echo "run_name=$run_name" >> $GITHUB_OUTPUT
echo "run_id=${run_id}" >> $GITHUB_OUTPUT
echo "run_url=$run_url" >> $GITHUB_OUTPUT
echo "### [${run_name}](${run_url})" >> $GITHUB_STEP_SUMMARY
deploy-check:
if: github.event.label.name == 'cicd:movement-containers' || github.ref == 'refs/heads/main'
needs: [deploy-trigger]
name: Deployment Check
runs-on: ubuntu-latest
steps:
- name: Wait for the deployment to complete
id: wait
env:
OWNER: movement-infra
REPO: cdktf-mvmt-networks
RUN_ID: ${{ needs.deploy-trigger.outputs.run_id }}
TOKEN: ${{ secrets.INFRA_GH_TOKEN }}
run: |
API_URL="https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${RUN_ID}"
while true; do
job_data=$(curl -sSL -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${TOKEN}" \
"$API_URL")
job_status=$(echo "$job_data" | jq -r '.status')
if [ "$job_status" = "completed" ]; then
completion_code=$(echo "$job_data" | jq -r '.conclusion')
if [ "$completion_code" = "success" ]; then
completion_msg="✅ Deployment was successful"
else
completion_msg="❌ Deployment failed, please check workflow for errors."
# exit 1
fi
echo "${completion_msg}"
echo "completion_code=${completion_code}" >> $GITHUB_OUTPUT
echo "completion_msg=${completion_msg}" >> $GITHUB_OUTPUT
echo "### ${completion_msg}" >> $GITHUB_STEP_SUMMARY
break
elif [ "$job_status" = "queued" ]; then
echo "⚫ Job queued, waiting for it to start..."
break
elif [ "$job_status" != "completed" ] && [ "$job_status" != 'in_progress' ]; then
echo "❌ Job failed with unknown status"
break
else
echo "⚪ Job is still running..."
fi
sleep 15
done
Loading