-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
71 lines (70 loc) · 2.13 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
name: 'Build and push image to Registry'
description: 'Build and push image to Registry'
inputs:
registry:
description: 'Registry url'
required: true
namespace:
description: 'Namespace'
required: true
password:
description: 'Password'
required: true
username:
description: 'Username'
required: false
default: "userdoesnotmatter"
image_name:
description: 'Image name'
required: true
tag:
description: 'Image tags'
required: true
push:
description: 'Push image to registry'
required: true
default: "true"
context:
description: 'Context'
required: false
default: "."
runs:
using: "composite"
steps:
- uses: actions/checkout@v2
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- name: Clean tag
uses: OpenSourcePolitics/clean-tag-action@master
id: clean_tag
with:
tag: ${{ inputs.tag }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Scaleway registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
- name: Cache Docker layers
if: ${{ inputs.push != 'true' }}
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ inputs.image_name }}-${{ inputs.tag }}
restore-keys: |
${{ runner.os }}-buildx-${{ inputs.image_name }}-
- name: Build and push
uses: docker/build-push-action@v3
with:
cache-from: type=local,src=/tmp/.buildx-cache,mode=max
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
push: ${{ inputs.push == 'true' }}
load: ${{ inputs.push != 'true' }}
build-args: |
DOCKER_IMAGE_NAME=${{ inputs.image_name }}
DOCKER_IMAGE_TAG=${{ steps.clean_tag.outputs.tag }}
DOCKER_IMAGE=${{ inputs.registry }}/${{ inputs.namespace }}/${{ inputs.image_name }}:${{ steps.clean_tag.outputs.tag }}
tags: ${{ inputs.registry }}/${{ inputs.namespace }}/${{ inputs.image_name }}:${{ steps.clean_tag.outputs.tag }}
context: ${{ inputs.context }}