Skip to content

Commit 08a8fc0

Browse files
Merge pull request #90 from step-security/fix_Docker-Image-Publish-Migration
chore: add publish docker image workflow and fixed readme versionings
2 parents 48b0a13 + b34a9f3 commit 08a8fc0

File tree

4 files changed

+63
-7
lines changed

4 files changed

+63
-7
lines changed

.github/workflows/docker.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish docker image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: 'Tag to release'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
if: startsWith(github.event.inputs.release_tag, 'v')
19+
steps:
20+
- name: Harden the runner (Audit all outbound calls)
21+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
22+
with:
23+
egress-policy: audit
24+
25+
- name: Checkout
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
- name: Validate tag format
28+
run: |
29+
TAG=${{ github.event.inputs.release_tag }}
30+
if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
31+
echo "❌ Invalid tag format: $TAG"
32+
exit 1
33+
fi
34+
echo "✅ Valid semver tag: $TAG"
35+
- name: Log in to GitHub Container Registry
36+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Set up QEMU for ARM builds
43+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
47+
48+
- name: Build and push Docker image
49+
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
50+
with:
51+
context: .
52+
push: true
53+
platforms: linux/amd64,linux/arm64
54+
tags: |
55+
ghcr.io/${{ github.repository }}:${{ github.event.inputs.release_tag }}

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM docker:stable@sha256:fd4d028713fd05a1fb896412805daed82c4a0cc84331d8dad00cb596d7ce3e3a
2+
RUN apk add --no-cache curl
23
COPY start-mongodb.sh /start-mongodb.sh
34
RUN chmod +x /start-mongodb.sh
45
ENTRYPOINT ["/start-mongodb.sh"]

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
node-version: ${{ matrix.node-version }}
3434

3535
- name: Start MongoDB
36-
uses: step-security/mongodb-github-action@1.12.0
36+
uses: step-security/mongodb-github-action@v1
3737
with:
3838
mongodb-version: ${{ matrix.mongodb-version }}
3939

@@ -73,7 +73,7 @@ jobs:
7373
node-version: ${{ matrix.node-version }}
7474
7575
- name: Start MongoDB
76-
uses: step-security/mongodb-github-action@1.12.0
76+
uses: step-security/mongodb-github-action@v1
7777
with:
7878
mongodb-version: ${{ matrix.mongodb-version }}
7979
mongodb-replica-set: test-rs
@@ -117,7 +117,7 @@ jobs:
117117
node-version: ${{ matrix.node-version }}
118118
119119
- name: Start MongoDB
120-
uses: step-security/mongodb-github-action@1.12.0
120+
uses: step-security/mongodb-github-action@v1
121121
with:
122122
mongodb-version: ${{ matrix.mongodb-version }}
123123
mongodb-replica-set: test-rs
@@ -161,7 +161,7 @@ jobs:
161161
node-version: ${{ matrix.node-version }}
162162
163163
- name: Start MongoDB
164-
uses: step-security/mongodb-github-action@1.12.0
164+
uses: step-security/mongodb-github-action@v1
165165
with:
166166
mongodb-version: ${{ matrix.mongodb-version }}
167167
mongodb-username: supercharge
@@ -205,7 +205,7 @@ jobs:
205205
node-version: ${{ matrix.node-version }}
206206
207207
- name: Start MongoDB
208-
uses: step-security/mongodb-github-action@1.12.0
208+
uses: step-security/mongodb-github-action@v1
209209
with:
210210
mongodb-version: ${{ matrix.mongodb-version }}
211211
mongodb-container-name: mongodb-${{ matrix.node-version }}-${{ matrix.mongodb-version }}
@@ -227,7 +227,7 @@ You can utilize an alternative MongoDB docker image using the `mongodb-image` in
227227

228228
```yaml
229229
- name: Start MongoDB
230-
uses: step-security/mongodb-github-action@1.12.0
230+
uses: step-security/mongodb-github-action@v1
231231
with:
232232
# Here we are using an image from Amazon's ECR rather than the default image from Docker Hub
233233
mongodb-image: 'public.ecr.aws/docker/library/mongo'

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ inputs:
4848

4949
runs:
5050
using: 'docker'
51-
image: 'Dockerfile'
51+
image: 'docker://ghcr.io/step-security/mongodb-github-action@sha256:14889a419431efee64b706e9307b5c2b15fe157b123b8f9f2fca9f8817dad835'
5252
args:
5353
- ${{ inputs.mongodb-image }}
5454
- ${{ inputs.mongodb-version }}

0 commit comments

Comments
 (0)