1
1
name : DockerImage build and push
2
2
3
3
on :
4
+ workflow_dispatch :
4
5
push :
5
- # Publish `v1.2.3` tags as releases.
6
- tags :
7
- - v*
6
+ branches :
7
+ - develop
8
+ - main
9
+ tags : ' *'
8
10
9
11
jobs :
10
12
# Push image to GitHub Packages.
11
13
push-op-geth :
12
14
runs-on : ubuntu-latest
13
- if : github.event_name == 'push'
14
15
15
16
steps :
16
17
- uses : actions/checkout@v3
@@ -22,28 +23,22 @@ jobs:
22
23
registry : ghcr.io
23
24
username : ${{ github.repository_owner }}
24
25
password : ${{ secrets.GITHUB_TOKEN }}
25
- - name : ImageId
26
- id : image
27
- run : |
28
- IMAGE_ID=ghcr.io/${{ github.repository_owner }}/op-geth
29
-
30
- # Change all uppercase to lowercase
31
- IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
32
- # Strip git ref prefix from version
33
- VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
34
- # Strip "v" prefix from tag name
35
- [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
36
- # Use Docker `latest` tag convention
37
- [ "$VERSION" == "main" ] && VERSION=latest
38
- echo "IMAGE_ID=$IMAGE_ID">>$GITHUB_OUTPUT
39
- echo "VERSION=$VERSION">>$GITHUB_OUTPUT
26
+ - name : image meta
27
+ id : meta
28
+ uses : docker/metadata-action@v5
29
+ with :
30
+ images : |
31
+ ghcr.io/${{ github.repository_owner }}/op-geth
32
+ tags : |
33
+ type=ref,event=branch
34
+ type=ref,event=tag
35
+ type=semver,pattern={{version}}
36
+ type=sha
40
37
- name : Build and push
41
38
uses : docker/build-push-action@v4
42
39
with :
43
40
context : .
44
41
file : ./Dockerfile
45
42
push : true
46
- tags : ${{ steps.image.outputs.IMAGE_ID }}:${{ steps.image.outputs.VERSION }},${{ steps.image.outputs.IMAGE_ID }}:latest
47
- cache-from : type=registry,ref=${{ steps.image.outputs.IMAGE_ID }}:buildcache
48
- cache-to : type=registry,ref=${{ steps.image.outputs.IMAGE_ID }}:buildcache,mode=max
49
-
43
+ tags : ${{ steps.meta.outputs.tags }}
44
+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments