-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add action to build docker on workflow dispatch
- Loading branch information
1 parent
79151e2
commit 8a8c408
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.github/workflows/docker.yml → .github/workflows/docker-auto.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: docker | ||
name: docker-auto | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: docker-manual | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
context_dir: | ||
type: string | ||
description: path to the directory containing the Dockerfile and meta.yml file (e.g. docker/r-quarto/) | ||
required: true | ||
push: | ||
type: boolean | ||
description: Push to DockerHub (uncheck to only build the container without pushing) | ||
required: true | ||
default: true | ||
|
||
jobs: | ||
build-docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pietrobolcato/[email protected] | ||
id: metadata | ||
with: | ||
config: ${{ github.workspace }}/${{ github.event.inputs.context_dir }}/meta.yml | ||
- name: Login to DockerHub | ||
if: ${{ github.event.inputs.push == 'true' }} | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Prepare build-time variables | ||
id: vars | ||
run: | | ||
echo "DATE=$(date +"%Y-%m-%d")" >> "$GITHUB_OUTPUT" | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
# only try building & pushing the container if parsing the metadata worked | ||
if: ${{ steps.metadata.outputs['container'] != '' }} | ||
with: | ||
context: ${{ github.event.inputs.context_dir }} | ||
push: ${{ github.event.inputs.push }} | ||
tags: ${{ steps.metadata.outputs['container'] }} | ||
build-args: | | ||
BUILD_DATE=${{ steps.vars.outputs.DATE }} | ||
BUILD_TAG=${{ steps.metadata.outputs['version'] }} | ||
REPONAME=${{ steps.metadata.outputs['image_name'] }} |