-
Notifications
You must be signed in to change notification settings - Fork 1
168 lines (143 loc) · 6 KB
/
push.yaml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: PUSH CI
on:
push:
branches:
- main
env:
GO_VERSION: 1.21
jobs:
commitlint_job:
name: Commit lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install commitlint
run: |
npm install --save-dev @commitlint/{cli,config-conventional}
- name: Validate current commit (last commit) with commitlint
run: npx commitlint --last --verbose
license_headers_job:
name: Add license headers
if: github.event.head_commit.committer.name != 'github-actions[bot]'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go environment
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
# Add all component folders for monorepos
cache-dependency-path: |
./registry/go.sum
./validator/go.sum
- name: Install NWA tool
run: go install github.com/B1NARY-GR0UP/nwa@latest
- name: Add missing license headers
run: nwa add -c "Syntio Ltd." -s **/*.xml ./registry ./validator
- name: Check and commit changes
id: check_commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
if ! git diff-index --quiet HEAD; then
git commit -m "style: add license headers"
echo "changes_committed=true" >> $GITHUB_ENV
else
echo "changes_committed=false" >> $GITHUB_ENV
echo "All necessary headers present."
fi
- name: Create a new branch for the PR
if: env.changes_committed == 'true'
run: |
git checkout -b "add-license-headers-${{ github.run_id }}"
git push origin HEAD
- name: Create pull request
if: env.changes_committed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --base ${{ github.ref_name }} --head "add-license-headers-${{ github.run_id }}" --title "style: add license headers" --body "This PR adds license headers to the affected files. Recommendation: Merge this PR using the rebase-merge method"
upload_docker_images_job:
if: github.event.head_commit.committer.name == 'github-actions[bot]' || startsWith(github.event.head_commit.message, 'feat') || startsWith(github.event.head_commit.message, 'fix')
name: Build, push and sign Docker images
runs-on: ubuntu-latest
permissions:
id-token: write # required to generate JWT token
strategy:
matrix:
component:
- dockerfile-path: ./validator/docker/csv-validator/Dockerfile
image-name: schema-registry-csv-val
- dockerfile-path: ./validator/docker/validator/Dockerfile
image-name: schema-registry-validator
- dockerfile-path: ./validator/docker/xml-validator/Dockerfile
image-name: schema-registry-xml-val
- dockerfile-path: ./registry/docker/compatibility-checker/Dockerfile
image-name: schema-registry-compatibility
- dockerfile-path: ./registry/docker/initdb/Dockerfile
image-name: schema-registry-initdb
- dockerfile-path: ./registry/docker/registry/Dockerfile
image-name: schema-registry-api
- dockerfile-path: ./registry/docker/validity-checker/Dockerfile
image-name: schema-registry-validity
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set image tag
run: |
if [ ${{ github.event.head_commit.committer.name }} == 'github-actions[bot]' ]; then
TAG=$(cat version.txt)
else
TAG=$(echo $GITHUB_SHA | cut -c 1-7)
fi
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Docker Hub Login
run: |
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Build Docker image
run: |
docker build -t ${{ matrix.component.image-name }}:${{ env.TAG }} -f ${{ matrix.component.dockerfile-path }} .
- name: Check if Docker image tag exists
run: |
if docker manifest inspect syntioinc/dataphos-${{ matrix.component.image-name }}:${{ env.TAG }} > /dev/null 2>&1; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Tag and Push Docker image
if: ${{ env.TAG_EXISTS == 'false' }}
run: |
docker tag ${{ matrix.component.image-name }}:${{ env.TAG }} syntioinc/dataphos-${{ matrix.component.image-name }}:${{ env.TAG }}
docker push syntioinc/dataphos-${{ matrix.component.image-name }}:${{ env.TAG }}
- name: Install cosign
if: ${{ github.event.head_commit.committer.name == 'github-actions[bot]' && env.TAG_EXISTS == 'false' }}
uses: sigstore/[email protected]
- name: Sign the Docker image
if: ${{ github.event.head_commit.committer.name == 'github-actions[bot]' && env.TAG_EXISTS == 'false' }}
run: |
digest=$(docker inspect --format='{{index .RepoDigests 0}}' syntioinc/dataphos-${{ matrix.component.image-name }}:${{ env.TAG }})
cosign sign --yes "$digest"
- name: Image already exists
if: ${{ env.TAG_EXISTS == 'true' }}
run: echo "Docker image syntioinc/dataphos-${{ matrix.component.image-name }}:${{ env.TAG }} already exists. Skipping push."
release-please:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
release-type: simple