-
Notifications
You must be signed in to change notification settings - Fork 2
/
.webhook-ci.yml
49 lines (44 loc) · 1.61 KB
/
.webhook-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
version: 2.1
orbs:
slack: circleci/[email protected]
workflows:
webhook:
jobs:
- trigger-workflow
jobs:
trigger-workflow:
docker:
- image: cimg/base:current
steps:
- run:
name: Filter only agent tagged images
command: |
export IMAGE_TAG="$(echo '<< pipeline.trigger_parameters.webhook.body >>' | jq .push_data.tag)"
# If workflow is triggered by a webhook, verify it was for a new "agent" tag for task-agent
if [[ "<< pipeline.trigger_source >>" = "webhook" ]]; then
# Halt the step if it wasn't triggered for a new "agent" image build on task-agent
if [[ ! "$IMAGE_TAG" = '"agent"' ]]; then
echo "Step halted because the image tag is not 'agent'."
circleci-agent step halt
fi
else
# We should never get here by automation, but just in case
echo "Step halted because the pipeline was not triggered by a webhook."
circleci-agent step halt
fi
- run:
name: Trigger Image Rebuild
command: |
curl -X POST "https://circleci.com/api/v2/project/github/circleci/runner-init/pipeline" \
--header "Circle-Token: $WEBHOOK_CCI_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{"parameters": {"triggered_by_webhook": true}}'
- notify_failing_main
commands:
notify_failing_main:
steps:
- slack/notify:
channel: runner-alerts
branch_pattern: main
event: fail
template: basic_fail_1