-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
99 lines (93 loc) · 3.1 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Docker Image Trigger
description: Build and push Docker images to GitHub Container registry easly
author: "mitch1009"
inputs:
git_token:
description: "Git token"
required: true
release_name:
description: "Release name"
required: true
release_version:
description: "Release version"
required: true
docker_image_vendor:
description: "Docker image vendor"
required: true
docker_context_path:
description: "Docker context path"
required: true
release_sha:
description: "Release SHA"
required: false
default: $(git rev-parse --short HEAD)
release_description:
description: "Release description"
required: false
default: '[$(git rev-parse --short HEAD)] New Docker Image Release $(jq -r ".version" package.json ) '
outputs:
tags:
description: "Docker image tags"
value: ${{ steps.meta.outputs.tags }}
labels:
description: "Docker image labels"
value: ${{ steps.meta.outputs.labels }}
release_sha:
description: "Release SHA"
value: ${{ steps.extract_sha.outputs.sha }}
runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: login to ghcr
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.git_token }}
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
flavor: |
latest=auto
images: |
ghcr.io/${{github.repository}}/${{inputs.release_name}}
tags: |
type=raw,value=${{ inputs.release_version }}
type=raw,value=latest
type=raw,value=${{ steps.extract_sha.outputs.sha }}
type=raw,value=${{ inputs.release_sha }}
labels: |
maintainer=${{ inputs.docker_image_vendor }}
org.opencontainers.image.vendor=${{ inputs.docker_image_vendor }}
org.opencontainers.image.title=${{ inputs.release_name }}
org.opencontainers.image.version=${{ inputs.release_version }}
org.opencontainers.image.description=${{ inputs.release_description }}
org.opencontainers.image.revision=${{ inputs.release_sha }}
org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Check current folder directory
shell: bash
id: extract_sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
context: ${{ inputs.docker_context_path }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
shell: bash
id: digest
run: echo ${{ steps.build-and-push.outputs.digest }}