Skip to content

Commit 8ceeda4

Browse files
authored
Make docker build action more consistent. (#4)
1 parent 4e13efd commit 8ceeda4

File tree

2 files changed

+17
-73
lines changed

2 files changed

+17
-73
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
name: build
1+
---
2+
name: Docker Build Action
23
on:
4+
pull_request:
5+
branches:
6+
- main
7+
release:
8+
types:
9+
- published
310
push:
411
branches:
5-
- "main"
6-
tags:
7-
- 'v*'
12+
- main
13+
814
env:
915
REGISTRY: ghcr.io
1016
IMAGE_NAME: ${{ github.repository }}
@@ -14,7 +20,6 @@ jobs:
1420
name: Build
1521
runs-on: ubuntu-latest
1622
steps:
17-
1823
- name: Set up Go 1.18
1924
uses: actions/setup-go@v2
2025
with:
@@ -36,21 +41,15 @@ jobs:
3641
username: ${{ github.actor }}
3742
password: ${{ secrets.GITHUB_TOKEN }}
3843

39-
- name: Extract metadata (tags, labels) for Docker
40-
id: meta
41-
uses: docker/metadata-action@v3
42-
with:
43-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44-
tags: |
45-
type=ref,event=branch
46-
type=ref,event=pr
47-
type=semver,pattern={{version}}
48-
type=semver,pattern={{major}}.{{minor}}
44+
- name: Make tag
45+
run: |
46+
[ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true
47+
[ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true
48+
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true
4949
50-
- name: Build and push Docker image
50+
- name: Build and push image
5151
uses: docker/build-push-action@v2
5252
with:
5353
context: .
5454
push: true
55-
tags: ${{ steps.meta.outputs.tags }}
56-
labels: ${{ steps.meta.outputs.labels }}
55+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }}

.github/workflows/pr.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)