-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (60 loc) · 2.14 KB
/
build-pre-release-image.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
name: Build image and push into registry
on:
workflow_call:
secrets:
docker_registry_username:
required: true
docker_registry_password:
required: true
inputs:
service:
required: false
type: string
default: .
use_docker_cache:
required: false
type: boolean
default: true
jobs:
release:
name: Build and push
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: docker-layer-caching
if: ${{ inputs.use_docker_cache }}
uses: jpribyl/[email protected]
continue-on-error: true
- uses: actions/cache@v4
with:
path: ~/.skaffold/
key: sk-${{ inputs.service }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
sk-${{ inputs.service }}-${{ github.ref_name }}-${{ github.sha }}
sk-${{ inputs.service }}-${{ github.ref_name }}
sk-${{ inputs.service }}
sk-
- name: Build and push docker image
run: |
mkdir -p ${HOME}/.local/bin
export PATH=${HOME}/.local/bin:${PATH}
curl -fsSLo skaffold "https://storage.googleapis.com/skaffold/releases/v1.24.1/skaffold-$(uname | tr '[:upper:]' '[:lower:]')-amd64"
chmod +x skaffold && mv skaffold "${HOME}/.local/bin"
skaffold config set --global collect-metrics false
printf "%s" "${DOCKER_PASSWORD}" | docker login -u ${DOCKER_USERNAME} --password-stdin cr.yandex
cat ~/.skaffold/cache || true
if [ ${WORKDIR} = "." ]; then
# simple case
skaffold build --file-output=$HOME/tags.json
else
# handling monorepo here
export TAG=$(git describe --tag --always --match "${TAG_PREFIX}*" | sed -e "s/${TAG_PREFIX}/v/")
skaffold build --file-output=$HOME/tags.json --tag $TAG -f ${WORKDIR}/skaffold.yaml
fi
env:
DOCKER_PASSWORD: ${{ secrets.docker_registry_password }}
DOCKER_USERNAME: ${{ secrets.docker_registry_username }}
WORKDIR: ${{ inputs.service }}
TAG_PREFIX: "${{ inputs.service }}-v"