-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
96 lines (96 loc) · 2.66 KB
/
action.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
96
name: 'Build Container Image'
description: 'Build and Push to Registry'
inputs:
# registry config
registry_name:
description: 'Container registry'
default: 'ghcr.io'
required: true
registry_username:
description: 'Username for container registry'
required: true
registry_password:
description: 'Password for container registry'
required: true
push:
description: 'Push container image to registry ?'
required: false
default: 'true'
# end
# docker config
context:
description: 'Docker build context'
required: true
default: '.'
dockerfile:
description: 'Dockerfile name'
required: true
default: 'Dockerfile'
image_name:
description: 'Name of image to working with'
required: true
image_tag:
description: 'Tag of image to working with. Default: latest'
required: true
default: 'latest'
target:
description: 'Multistage docker target'
required: false
default: ''
# end
# composer config
composer_github_auth:
description: 'Github token to enable composer to install private packages'
required: false
# end
# env config
copy_env:
description: 'Copy .env.example to .env'
required: false
default: 'true'
# end
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install
shell: sh
- name: build static assets
shell: sh
run: |
if [ "${{ inputs.copy_env }}" = "true" ]; then
cp .env.example .env
fi
npm run prod
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{inputs.image_name}}
restore-keys: |
${{ runner.os }}-buildx-${{inputs.image_name}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{inputs.registry_name}}
username: ${{inputs.registry_username}}
password: ${{inputs.registry_password}}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ${{inputs.context}}
push: ${{inputs.push}}
tags: ${{inputs.image_name}}:${{inputs.image_tag}}
file: ${{inputs.dockerfile}}
build-args: |
GITHUB_TOKEN=${{inputs.composer_github_auth}}
cache-from: type=registry,ref=${{inputs.image_name}}:buildcache
cache-to: type=registry,mode=max,ref=${{inputs.image_name}}:buildcache
target: ${{inputs.target}}