Docker #115
Workflow file for this run
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
name: Docker | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
# Run tests for any PRs. | |
pull_request: | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
# Run tests for pull-requests | |
# See also https://docs.docker.com/docker-hub/builds/automated-testing/ | |
test: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 1 | |
- name: Test build | |
uses: docker/build-push-action@v2 | |
with: | |
push: false | |
lint: | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Run super-Linter for Dockerfile | |
uses: github/super-linter@v4 | |
env: | |
VALIDATE_DOCKER: true | |
VALIDATE_DOCKER_HADOLINT: true | |
FILTER_REGEX_INCLUDE: .*(Dockerfile).* | |
DEFAULT_BRANCH: main | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Push image to GitHub Packages. | |
# See also https://docs.docker.com/docker-hub/builds/ | |
build-and-push: | |
# Ensure lint job passes before pushing image. | |
needs: | |
- lint | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Login into Container Registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata for Docker (tag) | |
id: meta_tag | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.REGISTRY }}/${{ github.repository }} | |
tags: | | |
type=ref,event=tag | |
- name: Extract metadata for Docker (bleeding) | |
id: meta_bleeding | |
if: false == startsWith(github.ref, 'refs/tags/v') | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.REGISTRY }}/${{ github.repository }} | |
tags: | | |
type=edge | |
type=sha,prefix= | |
- name: Build and push Docker image (tag) | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: ${{ steps.meta_tag.outputs.tags }} | |
labels: ${{ steps.meta_tag.outputs.labels }} | |
- name: Build and push Docker image (bleeding) | |
if: false == startsWith(github.ref, 'refs/tags/v') | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: ${{ steps.meta_bleeding.outputs.tags }} | |
labels: ${{ steps.meta_bleeding.outputs.labels }} |