Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build a docker image on merge to main #228

Merged
merged 4 commits into from
Feb 28, 2025
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
45 changes: 45 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ name: build-release
on:
push:
branches: [ "main" ]
workflow_dispatch:
inputs:
docker-tag-type:
description: The docker tag to upload as
required: true
default: latest
type: choice
options:
- latest
- stable

env:
CARGO_TERM_COLOR: always
Expand All @@ -14,6 +24,41 @@ permissions:
contents: read

jobs:
docker:
environment: Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: get tag
id: get-tag
run: |
if [[ "${DOCKER_TAG_TYPE}" = 'stable' ]]; then
tag="$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "mdq") | .version')"
else
tag=latest
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
env:
DOCKER_TAG_TYPE: ${{ inputs.docker-tag-type }}
DOCKER_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
- name: Gather metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKERHUB_USERNAME }}/mdq
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ vars.DOCKERHUB_USERNAME}}/mdq:${{ steps.get-tag.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}

build:
strategy:
matrix:
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ Any of these will work:
2. ```shell
brew install mdq
```
3. Download binaries from [the latest release] (or any other release, of course).
4. You can also grab the binaries from the latest [build-release] workflow run. You must be logged into GitHub to do
3. ```bash
docker pull yshavit/mdq
echo 'My [example](https://github.com/yshavit/mdq) markdown' | docker run --rm -i yshavit/mdq '[]()'
```
4. Download binaries from [the latest release] (or any other release, of course).

You can also grab the binaries from the latest [build-release] workflow run. You must be logged into GitHub to do
that (this is GitHub's limitation, not mine). You'll have to `chmod +x` them before you can run them.

<details>
Expand Down
Loading