Skip to content

Commit

Permalink
chore: change the way we create docker images and tags (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
srsp authored Nov 4, 2023
1 parent e5c4424 commit ad54e5c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 43 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/docker-image.yml

This file was deleted.

29 changes: 18 additions & 11 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
name: Docker Publish


on:
push:
tags: [ '*.*.*' ]
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- 'main'

env:
IMAGE_NAME: ansible-azure
REGISTRY_USER: srsp


jobs:
build:

Expand All @@ -21,20 +25,18 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3

uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USER }}
Expand All @@ -44,17 +46,22 @@ jobs:
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_USER }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![build](https://github.com/srsp/docker-ansible-azure/actions/workflows/docker-image.yml/badge.svg)
![build](https://github.com/srsp/docker-ansible-azure/actions/workflows/docker-publish.yml/badge.svg)
[![Docker Hub](https://img.shields.io/docker/v/srsp/ansible-azure?label=Docker%20Hub&logo=docker&logoColor=white)](https://hub.docker.com/r/srsp/ansible-azure)

# docker-ansible
Expand Down

0 comments on commit ad54e5c

Please sign in to comment.