This repository was archived by the owner on Mar 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathsfpowerscripts-build-docker.yml
More file actions
111 lines (92 loc) · 2.99 KB
/
Copy pathsfpowerscripts-build-docker.yml
File metadata and controls
111 lines (92 loc) · 2.99 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
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
100
101
102
103
104
105
106
107
108
109
110
111
name: Build and Publish sfpowerscripts Docker Image to ghcr
on:
workflow_call:
inputs:
job-environment:
type: string
required: true
repo:
type: string
required: true
dockerFileName:
type: string
required: false
default: sfpowerscripts
image:
type: string
required: false
default: sfpowerscripts
suffix-tag:
type: string
required: true
secrets:
username:
required: true
token:
required: true
jobs:
build:
name: 'build docker image'
environment: ${{ inputs.job-environment }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.username }}
password: ${{ secrets.token }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ inputs.repo }}/${{ inputs.image }}
- name: 'Get package version and name'
run: |
echo "PKG_VERSION=$(jq -r ".version" packages/sfpowerscripts-cli/package.json)" >> $GITHUB_ENV
RELEASE_NAME=$(jq -r ".release" packages/sfpowerscripts-cli/package.json)
RELEASE_NAME_AS_ARRAY=($RELEASE_NAME)
RELEASE_NAME=$(echo ${RELEASE_NAME_AS_ARRAY[0]} | cut -c1-3)${RELEASE_NAME_AS_ARRAY[1]}
echo "RELEASE_NAME=release-$RELEASE_NAME" >> $GITHUB_ENV
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
file: dockerfiles/${{inputs.dockerFileName}}.Dockerfile
context: dockerfiles
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
ghcr.io/${{ inputs.repo }}/${{ inputs.image }}:${{ env.PKG_VERSION }}-${{ inputs.suffix-tag }}
build-args: |
SFPOWERSCRIPTS_VERSION=${{ env.PKG_VERSION }}
GIT_COMMIT=${{ github.sha}}
#Tag the image as develop
- name: 'Tag Docker'
uses: ./.github/actions/tagDocker
with:
repo: ${{ inputs.repo }}
image: ${{ inputs.image }}
existing-tag: ${{ env.PKG_VERSION }}-${{ inputs.suffix-tag }}
new-tag: ${{ github.ref_name }}
registry: ghcr.io
username: ${{ secrets.username }}
token: ${{ secrets.token }}
#Tag the image as develop
- name: 'Tag Docker'
uses: ./.github/actions/tagDocker
with:
repo: ${{ inputs.repo }}
image: ${{ inputs.image }}
existing-tag: ${{ env.PKG_VERSION }}-${{ inputs.suffix-tag }}
new-tag: ${{ env.RELEASE_NAME }}
registry: ghcr.io
username: ${{ secrets.username }}
token: ${{ secrets.token }}