Skip to content

Removed quotes from tag #55

Removed quotes from tag

Removed quotes from tag #55

Workflow file for this run

name: Create and publish a Docker image
on:
workflow_dispatch: # Allow manually running
push:
branches:
# - 'main'
- 'test' #TODO! Remove this later
tags:
- 'v*'
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions: # Sets the permissions granted to the GITHUB_TOKEN for the actions in this job.
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3.0.0
with:
# This is your Docker Hub username and password.
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Uses the docker/login-action action to log in to the Container registry registry using the account and password that will publish the packages.
# Once published, the packages are scoped to the account defined here.
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses docker/metadata-action to extract tags and labels that will be applied to the specified image. https://github.com/docker/metadata-action
# The id "meta" allows the output of this step to be referenced in a subsequent step. The images value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.0.0
with:
images: |
${{ github.repository }} # minituff/nautical-backup
ghcr.io/${{ github.repository }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# output 0.1.2
type=semver,pattern={{version}}
# output 0.1
type=semver,pattern={{major}}.{{minor}}
# disabled if major zero
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
- name: Build and export to Docker
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ github.repository }}:test
- name: Test Docker image
# docker run --rm "${{ fromJSON(steps.meta.outputs.json).tags[0] }}-test"
run: |
cd tests
docker run --rm ${{ github.repository }}:test \
--name nautical-backup \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /source:/app/source \
-v /destination:/app/destination \
-e LOG_LEVEL="INFO" \
-e EXIT_AFTER_INIT="true" \
-e BACKUP_ON_START="true" \
--build-arg="NAUTICAL_VERSION="test"
# This step uses the docker/build-push-action action to build the image, based on your repository's Dockerfile.
# It uses the context parameter to define the build's context as the set of files located in the specified path.
# For more information, see "Usage" in the README of the docker/build-push-action repository. https://github.com/docker/build-push-action#usage
# It uses the tags and labels parameters to tag and label the image with the output from the "meta" step.
# - name: Build and push Docker images
# uses: docker/build-push-action@v5.0.0
# with:
# context: .
# push: true
# platforms: linux/amd64,linux/arm64
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# build-args: |
# NAUTICAL_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}