Skip to content

Commit e8a8df1

Browse files
authored
Merge pull request #72 from ukeeper/worktree-ci-hardening
2 parents 884ed3f + f214eb6 commit e8a8df1

874 files changed

Lines changed: 81627 additions & 47608 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ updates:
1414
patterns:
1515
- "*"
1616
- package-ecosystem: "gomod"
17-
directory: "/backend"
17+
directory: "/"
1818
schedule:
1919
interval: "monthly"
2020
groups:

.github/workflows/ci.yml

Lines changed: 5 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ permissions:
1212
jobs:
1313
build:
1414
runs-on: ubuntu-latest
15+
services:
16+
mongodb:
17+
image: mongo:5.0
18+
ports:
19+
- 27017:27017
1520

1621
steps:
1722
- name: checkout
@@ -25,11 +30,6 @@ jobs:
2530
go-version: "1.25"
2631
id: go
2732

28-
- name: launch mongodb
29-
uses: wbari/start-mongoDB@v0.2
30-
with:
31-
mongoDBVersion: "5.0"
32-
3333
- name: build and test
3434
run: |
3535
go test -timeout=60s -race -covermode=atomic -coverprofile=$GITHUB_WORKSPACE/profile.cov ./...
@@ -49,176 +49,3 @@ jobs:
4949
goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov
5050
env:
5151
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
53-
docker:
54-
needs: build
55-
if: github.event_name == 'push'
56-
strategy:
57-
fail-fast: false
58-
matrix:
59-
include:
60-
- platform: linux/amd64
61-
runner: ubuntu-latest
62-
artifact: linux-amd64
63-
- platform: linux/arm64
64-
runner: ubuntu-24.04-arm
65-
artifact: linux-arm64
66-
runs-on: ${{ matrix.runner }}
67-
permissions:
68-
contents: read
69-
packages: write
70-
71-
steps:
72-
- name: checkout
73-
uses: actions/checkout@v6
74-
with:
75-
persist-credentials: false
76-
77-
- name: set up Docker Buildx
78-
uses: docker/setup-buildx-action@v4
79-
80-
- name: login to ghcr.io
81-
uses: docker/login-action@v3
82-
with:
83-
registry: ghcr.io
84-
username: ${{ github.actor }}
85-
password: ${{ secrets.PKG_TOKEN }}
86-
87-
- name: login to DockerHub
88-
uses: docker/login-action@v3
89-
with:
90-
username: ${{ github.actor }}
91-
password: ${{ secrets.DOCKER_HUB_TOKEN }}
92-
93-
- name: build and push to ghcr.io by digest
94-
id: build-ghcr
95-
uses: docker/build-push-action@v6
96-
with:
97-
context: .
98-
platforms: ${{ matrix.platform }}
99-
build-args: |
100-
CI=github
101-
GITHUB_SHA=${{ github.sha }}
102-
GIT_BRANCH=${{ github.ref_name }}
103-
outputs: type=image,name=ghcr.io/ukeeper/ukeeper-readability,push-by-digest=true,name-canonical=true,push=true
104-
105-
- name: build and push to DockerHub by digest
106-
id: build-dockerhub
107-
uses: docker/build-push-action@v6
108-
with:
109-
context: .
110-
platforms: ${{ matrix.platform }}
111-
build-args: |
112-
CI=github
113-
GITHUB_SHA=${{ github.sha }}
114-
GIT_BRANCH=${{ github.ref_name }}
115-
outputs: type=image,name=umputun/ukeeper-readability,push-by-digest=true,name-canonical=true,push=true
116-
117-
- name: export digests
118-
run: |
119-
mkdir -p /tmp/digests/ghcr /tmp/digests/dockerhub
120-
digest_ghcr="${{ steps.build-ghcr.outputs.digest }}"
121-
digest_dockerhub="${{ steps.build-dockerhub.outputs.digest }}"
122-
touch "/tmp/digests/ghcr/${digest_ghcr#sha256:}"
123-
touch "/tmp/digests/dockerhub/${digest_dockerhub#sha256:}"
124-
125-
- name: upload ghcr digest
126-
uses: actions/upload-artifact@v4
127-
with:
128-
name: digests-ghcr-${{ matrix.artifact }}
129-
path: /tmp/digests/ghcr/*
130-
retention-days: 1
131-
132-
- name: upload dockerhub digest
133-
uses: actions/upload-artifact@v4
134-
with:
135-
name: digests-dockerhub-${{ matrix.artifact }}
136-
path: /tmp/digests/dockerhub/*
137-
retention-days: 1
138-
139-
docker-merge:
140-
needs: docker
141-
runs-on: ubuntu-latest
142-
permissions:
143-
contents: read
144-
packages: write
145-
146-
steps:
147-
- name: download ghcr digests
148-
uses: actions/download-artifact@v4
149-
with:
150-
path: /tmp/digests/ghcr
151-
pattern: digests-ghcr-*
152-
merge-multiple: true
153-
154-
- name: download dockerhub digests
155-
uses: actions/download-artifact@v4
156-
with:
157-
path: /tmp/digests/dockerhub
158-
pattern: digests-dockerhub-*
159-
merge-multiple: true
160-
161-
- name: verify all digests present
162-
run: |
163-
for registry in ghcr dockerhub; do
164-
expected=2
165-
actual=$(find /tmp/digests/$registry -maxdepth 1 -type f | wc -l)
166-
if [ "$actual" -ne "$expected" ]; then
167-
echo "Expected $expected digests for $registry, found $actual"
168-
ls -la /tmp/digests/$registry
169-
exit 1
170-
fi
171-
done
172-
echo "All digests present"
173-
174-
- name: set up Docker Buildx
175-
uses: docker/setup-buildx-action@v4
176-
177-
- name: login to ghcr.io
178-
uses: docker/login-action@v3
179-
with:
180-
registry: ghcr.io
181-
username: ${{ github.actor }}
182-
password: ${{ secrets.PKG_TOKEN }}
183-
184-
- name: login to DockerHub
185-
uses: docker/login-action@v3
186-
with:
187-
username: ${{ github.actor }}
188-
password: ${{ secrets.DOCKER_HUB_TOKEN }}
189-
190-
- name: determine tags
191-
id: tags
192-
run: |
193-
ref="${GITHUB_REF#refs/*/}"
194-
ref="${ref//\//_}"
195-
echo "ref=${ref}" >> $GITHUB_OUTPUT
196-
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
197-
echo "is_tag=true" >> $GITHUB_OUTPUT
198-
else
199-
echo "is_tag=false" >> $GITHUB_OUTPUT
200-
fi
201-
202-
- name: create ghcr.io manifest and push
203-
working-directory: /tmp/digests/ghcr
204-
run: |
205-
ref="${{ steps.tags.outputs.ref }}"
206-
is_tag="${{ steps.tags.outputs.is_tag }}"
207-
tags="-t ghcr.io/ukeeper/ukeeper-readability:${ref}"
208-
if [[ "$is_tag" == "true" ]]; then
209-
tags="${tags} -t ghcr.io/ukeeper/ukeeper-readability:latest"
210-
fi
211-
docker buildx imagetools create ${tags} \
212-
$(printf 'ghcr.io/ukeeper/ukeeper-readability@sha256:%s ' *)
213-
214-
- name: create DockerHub manifest and push
215-
working-directory: /tmp/digests/dockerhub
216-
run: |
217-
ref="${{ steps.tags.outputs.ref }}"
218-
is_tag="${{ steps.tags.outputs.is_tag }}"
219-
tags="-t umputun/ukeeper-readability:${ref}"
220-
if [[ "$is_tag" == "true" ]]; then
221-
tags="${tags} -t umputun/ukeeper-readability:latest"
222-
fi
223-
docker buildx imagetools create ${tags} \
224-
$(printf 'umputun/ukeeper-readability@sha256:%s ' *)

0 commit comments

Comments
 (0)