Merge pull request #2 from eimis-ans/fix/publish #2
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: Publish Docker image | |
on: | |
push: | |
branches: [main] | |
tags: ["v*"] | |
concurrency: | |
group: docker-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
lint: | |
uses: ./.github/workflows/lint.yml | |
publish-docker-images: | |
needs: lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Set up context | |
id: project_context | |
uses: FranzDiebold/github-env-vars-action@v2.7.0 | |
- name: Extract metadata (tags, labels) for Docker | |
id: docker_metadata | |
uses: docker/metadata-action@v4 | |
with: | |
images: eimisans/ma1sd-extender | |
tags: | | |
type=raw,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }},value=${{ env.CI_ACTION_REF_NAME_SLUG }} | |
type=raw,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }},value=nightly | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
labels: | | |
org.opencontainers.image.vendor=EIMIS | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ vars.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build and publish image(s) | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
labels: ${{ steps.docker_metadata.outputs.labels }} | |
dockerhub-description: | |
needs: publish-docker-images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Find change in readme file | |
id: readme-change | |
uses: tj-actions/changed-files@v34 | |
with: | |
files: | | |
README.md | |
- name: Docker Hub Description | |
if: steps.readme-change.outputs.any_changed == 'true' | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USER }} | |
short-description: Docker image for https://github.com/${{ github.repository }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
repository: ${{ github.repository }} | |
readme-filepath: README.md |