generated from atls-lab/template
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (85 loc) · 3.18 KB
/
pack-image.yaml
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
name: Pack image
on:
workflow_call:
inputs:
registryURL:
description: 'Where to publish built docker image. Github - `ghcr.io`. Yandex - `cr.yandex`'
required: true
type: string
registryUser:
description: 'How to authenticate user. For yandex - `oauth`, `iam`, `json_key`. For GitHub - repo owner'
type: string
required: true
project:
description: 'Project name for publishing to registry. For GitHub - repo name.'
type: string
required: false
imageNamePrefix:
description: 'Image name prefix'
required: false
type: string
nodeVersion:
description: 'Node version to run this workflow. Default: 22'
default: '22'
required: false
type: string
escapeCharactersInKey:
required: false
default: true
type: boolean
description: 'Login via echo -e. Default: true'
secrets:
registryKey:
required: true
description: 'Login key for registry'
project:
required: false
description: 'Project name for publishing to registry. For GitHub - repo name.'
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: master
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodeVersion }}
- name: Yarn cache directory
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Yarn install
run: yarn install --inline-builds
- name: Install Buildpack CLI
run: |
(curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.36.2/pack-v0.36.2-linux.tgz" | sudo tar -C /usr/local/bin/ --no-same-owner -xzv pack)
- name: Login to registry
run: |
if [[ $ESCAPE_CHARACTERS == "true" || $ESCAPE_CHARACTERS == true ]] ; then
echo -e "$REGISTRY_KEY" | docker login $REGISTRY_URL -u $USERNAME --password-stdin
else
echo "$REGISTRY_KEY" | docker login $REGISTRY_URL -u $USERNAME --password-stdin
fi
env:
REGISTRY_KEY: ${{ secrets.registryKey }}
USERNAME: ${{ inputs.registryUser }}
REGISTRY_URL: ${{ inputs.registryURL }}
ESCAPE_CHARACTERS: ${{ inputs.escapeCharactersInKey }}
- name: Pack and publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REGISTRY_URL: ${{ inputs.registryURL }}
PROJECT: ${{ secrets.project != '' && secrets.project || inputs.project }}
IMAGE_NAME_PREFIX: ${{ inputs.imageNamePrefix }}
run: |
PROJECT_LOWER=$(echo "$PROJECT" | tr '[:upper:]' '[:lower:]')
yarn workspaces changed foreach -vpj 2 image pack --publish --tag-policy hash-timestamp --registry "$REGISTRY_URL/$PROJECT_LOWER/$IMAGE_NAME_PREFIX"