Skip to content

Commit d7de55e

Browse files
authored
chore: fork CI (#4051)
1 parent d1f4cd5 commit d7de55e

3 files changed

Lines changed: 195 additions & 6 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,10 @@ jobs:
522522
run: |
523523
nix develop --impure .#ci -c make lint-helm
524524
525-
artifacts:
525+
trusted-artifacts:
526526
name: Artifacts
527527
uses: ./.github/workflows/artifacts.yaml
528+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
528529
with:
529530
publish: ${{ github.event_name == 'push' }}
530531
permissions:
@@ -533,6 +534,23 @@ jobs:
533534
id-token: write
534535
security-events: write
535536

537+
untrusted-artifacts:
538+
name: Untrusted Artifacts
539+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
540+
uses: ./.github/workflows/untrusted-artifacts.yaml
541+
permissions:
542+
contents: read
543+
544+
artifacts-pass:
545+
name: Artifacts
546+
needs:
547+
- trusted-artifacts
548+
- untrusted-artifacts
549+
if: ${{ always() }}
550+
uses: ./.github/workflows/workflow-result.yaml
551+
with:
552+
result: ${{ contains(needs.*.result, 'failure') && 'fail' || 'pass' }}
553+
536554
dependency-review:
537555
name: Dependency review
538556
runs-on: ubuntu-latest
@@ -568,7 +586,9 @@ jobs:
568586
name: Quickstart
569587
runs-on: depot-ubuntu-latest-8
570588
needs:
571-
- artifacts
589+
- trusted-artifacts
590+
- untrusted-artifacts
591+
if: ${{ !cancelled() && !contains(needs.*.result, 'failure') && contains(needs.*.result, 'success') }}
572592

573593
steps:
574594
- name: Checkout repository
@@ -577,8 +597,9 @@ jobs:
577597
persist-credentials: false
578598

579599
- name: Create override files for quickstart
600+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
580601
env:
581-
DEPOT_IMAGE_URL: ${{ needs.artifacts.outputs.container-image-url-depot }}
602+
DEPOT_IMAGE_URL: ${{ needs.trusted-artifacts.outputs.container-image-url-depot }}
582603
run: |
583604
cat > quickstart/docker-compose.override.yaml <<EOF
584605
services:
@@ -605,7 +626,36 @@ jobs:
605626
docker ps -a
606627
docker network ls
607628
echo "### DEBUG"
608-
629+
- name: Build as part of quickstart
630+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
631+
run: |
632+
cat > quickstart/docker-compose.override.yaml <<EOF
633+
services:
634+
openmeter:
635+
image: openmeter-quickstart-openmeter:ci
636+
pull_policy: build
637+
build: ..
638+
sink-worker:
639+
image: openmeter-quickstart-sink-worker:ci
640+
pull_policy: build
641+
build: ..
642+
balance-worker:
643+
image: openmeter-quickstart-balance-worker:ci
644+
pull_policy: build
645+
build: ..
646+
notification-service:
647+
image: openmeter-quickstart-notification-service:ci
648+
pull_policy: build
649+
build: ..
650+
billing-worker:
651+
image: openmeter-quickstart-billing-worker:ci
652+
pull_policy: build
653+
build: ..
654+
openmeter-jobs:
655+
image: openmeter-quickstart-openmeter-jobs:ci
656+
pull_policy: build
657+
build: ..
658+
EOF
609659
- name: Launch Docker Compose
610660
run: docker compose -f docker-compose.yaml -f docker-compose.override.yaml up -d
611661
working-directory: quickstart
@@ -666,7 +716,9 @@ jobs:
666716
runs-on: depot-ubuntu-latest-8
667717
# Note: This check is running against the image that is going to be pushed.
668718
needs:
669-
- artifacts
719+
- trusted-artifacts
720+
- untrusted-artifacts
721+
if: ${{ !cancelled() && !contains(needs.*.result, 'failure') && contains(needs.*.result, 'success') }}
670722

671723
steps:
672724
- name: Checkout repository
@@ -676,7 +728,8 @@ jobs:
676728

677729
- name: Create override files for e2e
678730
env:
679-
DEPOT_IMAGE_URL: ${{ needs.artifacts.outputs.container-image-url-depot }}
731+
DEPOT_IMAGE_URL: ${{ needs.trusted-artifacts.outputs.container-image-url-depot }}
732+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
680733
run: |
681734
cat > e2e/docker-compose.override.yaml <<EOF
682735
services:
@@ -695,6 +748,18 @@ jobs:
695748
docker ps -a
696749
docker network ls
697750
echo "### DEBUG"
751+
- name: Build as part of e2e
752+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
753+
run: |
754+
cat > e2e/docker-compose.override.yaml <<EOF
755+
services:
756+
openmeter:
757+
build: ..
758+
sink-worker:
759+
build: ..
760+
EOF
761+
762+
cat e2e/docker-compose.override.yaml
698763
699764
- name: Launch Docker Compose infra
700765
run: docker compose -f docker-compose.infra.yaml -f docker-compose.openmeter.yaml -f docker-compose.override.yaml up -d
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Untrusted Artifacts
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
container-image:
11+
name: Container image
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
with:
21+
persist-credentials: false
22+
23+
- name: Set image name
24+
id: image-name
25+
run: echo "value=ghcr.io/${{ github.repository }}" >> "$GITHUB_OUTPUT"
26+
27+
- name: Gather build metadata
28+
id: meta
29+
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
30+
with:
31+
images: ${{ steps.image-name.outputs.value }}
32+
flavor: |
33+
latest = false
34+
tags: |
35+
type=ref,event=branch
36+
type=ref,event=pr,prefix=pr-
37+
type=semver,pattern={{raw}}
38+
type=raw,value=latest,enable={{is_default_branch}}
39+
type=ref,event=branch,suffix=-{{sha}}-{{date 'X'}},enable={{is_default_branch}}
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
43+
44+
- name: Build image
45+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
46+
with:
47+
context: .
48+
build-args: |
49+
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
50+
platforms: linux/amd64
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
push: false
54+
55+
benthos-collector-container-image:
56+
name: Benthos Collector Container image
57+
runs-on: ubuntu-latest
58+
59+
permissions:
60+
contents: read
61+
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
65+
with:
66+
persist-credentials: false
67+
68+
- name: Set image name
69+
id: image-name
70+
run: echo "value=ghcr.io/openmeterio/benthos-collector" >> "$GITHUB_OUTPUT"
71+
72+
- name: Gather build metadata
73+
id: meta
74+
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
75+
with:
76+
images: ${{ steps.image-name.outputs.value }}
77+
flavor: |
78+
latest = false
79+
tags: |
80+
type=ref,event=branch
81+
type=ref,event=pr,prefix=pr-
82+
type=semver,pattern={{raw}}
83+
type=raw,value=latest,enable={{is_default_branch}}
84+
type=ref,event=branch,suffix=-{{sha}}-{{date 'X'}},enable={{is_default_branch}}
85+
86+
- name: Set up Docker Buildx
87+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
88+
89+
- name: Build image
90+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
91+
with:
92+
context: .
93+
file: benthos-collector.Dockerfile
94+
build-args: |
95+
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
96+
platforms: linux/amd64
97+
tags: ${{ steps.meta.outputs.tags }}
98+
labels: ${{ steps.meta.outputs.labels }}
99+
push: false
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Workflow Result for Required Check
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
result:
7+
description: Workflow result
8+
required: true
9+
type: string
10+
11+
jobs:
12+
workflow_result:
13+
name: Workflow Result
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 2
16+
steps:
17+
- name: Pass or Fail
18+
run: |
19+
if [[ "$INPUTS_RESULT" == true ]]; then
20+
exit 1
21+
else
22+
exit 0
23+
fi
24+
env:
25+
INPUTS_RESULT: ${{ inputs.result == 'fail' }}

0 commit comments

Comments
 (0)