-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaction.yml
More file actions
117 lines (105 loc) · 3.65 KB
/
action.yml
File metadata and controls
117 lines (105 loc) · 3.65 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: "Schema Validator Action"
description: "Validates schema compatibility with schema registry"
inputs:
# general inputs
checkout-repo-fetch-depth:
description: "number of commits to fetch"
required: false
default: "0"
# image inputs
image-tag:
description: "Image tag to use"
required: false
default: "latest"
# aws inputs
aws-role-duration-seconds:
description: ""
required: false
default: "900"
aws-region:
description: ""
required: false
aws-account-number:
description: ""
required: false
aws-role-arn:
description: ""
required: false
runs:
using: composite
steps:
- name: Checkout repo
uses: actions/checkout@v4.3.1
with:
fetch-depth: ${{ inputs.checkout-repo-fetch-depth }}
- name: Detect changed files
shell: bash
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
git fetch --prune origin +refs/heads/*:refs/remotes/origin/*
# Collect the changed files from the default branch
changed_files=$(git diff --name-only origin/${{ env.DEFAULT_BRANCH }})
# Each file is prefixed with './' on its own line.
{
echo "CHANGED_FILES<<EOF"
for file in $changed_files; do
echo "./$file"
done
echo "EOF"
} >> "$GITHUB_ENV"
- name: Start Redpanda with Docker Compose
shell: bash
env:
ACTIONS_PATH: ${{ github.action_path }}
run: |
docker compose -f "${{ env.ACTIONS_PATH }}/docker-compose.yml" up -d redpanda-console
- name: Configure aws creds
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ inputs.aws-role-arn }}
role-duration-seconds: ${{ inputs.aws-role-duration-seconds }}
aws-region: ${{ inputs.aws-region }}
mask-aws-account-id: true
- name: Login to aws ecr
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registries: ${{ inputs.aws-account-number }}
- name: Pull schema-validator image from ECR
shell: bash
env:
IMAGE_TAG: ${{ inputs.image-tag }}
run: |
docker pull ${{ steps.login-ecr.outputs.registry }}/atlas-beholder-schema-validator:${{ env.IMAGE_TAG }}
- name: Validate schemas in default branch
shell: bash
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
IMAGE_TAG: ${{ inputs.image-tag }}
run: |
# Store current branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Checkout and validate the default branch
git checkout ${{ env.DEFAULT_BRANCH }}
docker run -v "$PWD:/usr/src/app/repo" \
--network redpanda_network \
-e SCHEMA_REGISTRY_URL=http://redpanda-0:8081 \
${{ steps.login-ecr.outputs.registry }}/atlas-beholder-schema-validator:${{ env.IMAGE_TAG }} \
validate --phase master
# Return to original branch
git checkout $CURRENT_BRANCH
- name: Validate schemas in current branch (PR phase)
if: ${{ github.ref_name != github.event.repository.default_branch }}
shell: bash
env:
CHANGED_FILES: ${{ env.CHANGED_FILES }}
IMAGE_TAG: ${{ inputs.image-tag }}
run: |
# Validate only changed schemas
docker run -v "$PWD:/usr/src/app/repo" \
--network redpanda_network \
-e SCHEMA_REGISTRY_URL=http://redpanda-0:8081 \
-e CHANGED_FILES \
${{ steps.login-ecr.outputs.registry }}/atlas-beholder-schema-validator:${{ env.IMAGE_TAG }} \
validate --phase pr