Skip to content

Commit 47c00d7

Browse files
committed
ci: secret job to check for invalid secrets
Signed-off-by: CrazyMax <[email protected]>
1 parent 871b930 commit 47c00d7

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,29 @@ jobs:
302302
run: |
303303
docker image inspect myimage:latest
304304
305+
secret:
306+
runs-on: ubuntu-latest
307+
steps:
308+
-
309+
name: Checkout
310+
uses: actions/checkout@v3
311+
-
312+
name: Set up Docker Buildx
313+
uses: docker/setup-buildx-action@v2
314+
with:
315+
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
316+
driver-opts: |
317+
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
318+
-
319+
name: Build
320+
uses: ./
321+
with:
322+
context: .
323+
file: ./test/secret.Dockerfile
324+
secrets: |
325+
MYSECRET=foo
326+
INVALID_SECRET=
327+
305328
network:
306329
runs-on: ubuntu-latest
307330
steps:

__tests__/buildx.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ describe('getSecret', () => {
137137
}
138138
expect(true).toBe(!invalid);
139139
expect(secret).toEqual(`id=${exKey},src=${tmpNameSync}`);
140-
const secretValue = await fs.readFileSync(tmpNameSync, 'utf-8');
141-
expect(secretValue).toEqual(exValue);
140+
expect(fs.readFileSync(tmpNameSync, 'utf-8')).toEqual(exValue);
142141
} catch (err) {
143142
// eslint-disable-next-line jest/no-conditional-expect
144143
expect(true).toBe(invalid);

test/secret.Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# syntax=docker/dockerfile:1
2+
FROM busybox
3+
RUN --mount=type=secret,id=MYSECRET \
4+
echo "MYSECRET=$(cat /run/secrets/MYSECRET)"

0 commit comments

Comments
 (0)