-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_github_createAndReleaseActionDockerImage.yml
More file actions
47 lines (42 loc) · 1.96 KB
/
_github_createAndReleaseActionDockerImage.yml
File metadata and controls
47 lines (42 loc) · 1.96 KB
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
name: Create and Release Action Docker Image
on:
workflow_call:
inputs:
actionPath:
description: 'Path to the action directory containing Dockerfile'
required: true
type: string
imageName:
description: 'Name of the Docker image (without registry prefix)'
required: true
type: string
registryPrefix:
description: 'Container registry prefix'
required: false
type: string
default: 'ghcr.io/encoredigitalgroup'
secrets:
token:
description: 'GitHub token for authentication'
required: true
jobs:
BuildAndPushDockerImage:
name: Build and Push Docker Image (${{inputs.imageName}})
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
run: echo ${{ secrets.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Push Docker Image
run: |
cd ${{ inputs.actionPath }}
docker build -t ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:latest .
docker tag ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:latest ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:${{ github.ref_name }}
docker push ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:latest
docker push ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:${{ github.ref_name }}
- name: Output Image Details
run: |
echo "Docker image built and pushed successfully:"
echo "Image: ${{ inputs.registryPrefix }}/${{ inputs.imageName }}"
echo "Tags: latest, ${{ github.ref_name }}"