Skip to content

Commit

Permalink
Add GitHub Actions workflow to publish Docker container images to Doc…
Browse files Browse the repository at this point in the history
…ker Hub for "next" branch and semver tag pushes.
  • Loading branch information
DavidAnson authored Jul 18, 2022
1 parent d5ac854 commit 6dfbe1e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/publish-container-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish Docker container image to Docker Hub

on:
push:
branches:
- next
tags:
- v*

jobs:
publish:
runs-on: ubuntu-latest
permissions:
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to registry
uses: docker/login-action@v2.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract tags and labels
id: meta
uses: docker/metadata-action@v4.0.1
with:
images: ${{ github.repository }}

- name: Build container image
uses: docker/build-push-action@v3.0.0
with:
context: .
file: docker/Dockerfile
tags: local:test
labels: ${{ steps.meta.outputs.labels }}
load: true

- name: Test container image
run: docker run --rm -v $PWD:/workdir local:test "*.md"

- name: Push container image
uses: docker/build-push-action@v3.0.0
with:
context: .
file: docker/Dockerfile
platforms: linux/arm64,linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
11 changes: 5 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ COPY . .
RUN npm pack

FROM node:lts-alpine
# hadolint ignore=DL3010
COPY --from=build /pack/markdownlint-cli2-*.tgz /
RUN npm install --global --no-package-lock --production markdownlint-cli2-*.tgz && \
rm /markdownlint-cli2-*.tgz
Expand All @@ -15,8 +14,8 @@ WORKDIR /workdir

ENTRYPOINT ["/usr/local/bin/markdownlint-cli2"]

LABEL org.opencontainers.image.description="A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the `markdownlint` library"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/DavidAnson/markdownlint-cli2"
LABEL org.opencontainers.image.title="markdownlint-cli2"
LABEL org.opencontainers.image.url="https://github.com/DavidAnson/markdownlint-cli2"
# LABEL org.opencontainers.image.description="A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint library"
# LABEL org.opencontainers.image.licenses="MIT"
# LABEL org.opencontainers.image.source="https://github.com/DavidAnson/markdownlint-cli2"
# LABEL org.opencontainers.image.title="markdownlint-cli2"
# LABEL org.opencontainers.image.url="https://github.com/DavidAnson/markdownlint-cli2"

0 comments on commit 6dfbe1e

Please sign in to comment.