Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish docker image

on:
workflow_dispatch:
inputs:
release_tag:
description: 'Tag to release'
required: true
type: string

permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-latest
if: startsWith(github.event.inputs.release_tag, 'v')
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Validate tag format
run: |
TAG=${{ github.event.inputs.release_tag }}
if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "❌ Invalid tag format: $TAG"
exit 1
fi
echo "✅ Valid semver tag: $TAG"
- name: Log in to GitHub Container Registry
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU for ARM builds
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0

- name: Build and push Docker image
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}:${{ github.event.inputs.release_tag }}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM docker:stable@sha256:fd4d028713fd05a1fb896412805daed82c4a0cc84331d8dad00cb596d7ce3e3a
RUN apk add --no-cache curl
COPY start-mongodb.sh /start-mongodb.sh
RUN chmod +x /start-mongodb.sh
ENTRYPOINT ["/start-mongodb.sh"]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.12.0
uses: step-security/mongodb-github-action@v1
with:
mongodb-version: ${{ matrix.mongodb-version }}

Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.12.0
uses: step-security/mongodb-github-action@v1
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: test-rs
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.12.0
uses: step-security/mongodb-github-action@v1
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: test-rs
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.12.0
uses: step-security/mongodb-github-action@v1
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-username: supercharge
Expand Down Expand Up @@ -205,7 +205,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.12.0
uses: step-security/mongodb-github-action@v1
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-container-name: mongodb-${{ matrix.node-version }}-${{ matrix.mongodb-version }}
Expand All @@ -227,7 +227,7 @@ You can utilize an alternative MongoDB docker image using the `mongodb-image` in

```yaml
- name: Start MongoDB
uses: step-security/mongodb-github-action@1.12.0
uses: step-security/mongodb-github-action@v1
with:
# Here we are using an image from Amazon's ECR rather than the default image from Docker Hub
mongodb-image: 'public.ecr.aws/docker/library/mongo'
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inputs:

runs:
using: 'docker'
image: 'Dockerfile'
image: 'docker://ghcr.io/step-security/mongodb-github-action@sha256:14889a419431efee64b706e9307b5c2b15fe157b123b8f9f2fca9f8817dad835'
args:
- ${{ inputs.mongodb-image }}
- ${{ inputs.mongodb-version }}
Expand Down