-
Notifications
You must be signed in to change notification settings - Fork 35
/
action.yml
48 lines (45 loc) · 1.36 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
name: Setup docker-compose
description: Build and tag the Dockerfile to enable its use with docker-compose
inputs:
service:
required: false
default: web
description: Name of the service that uses the Dockerfile
cache-from:
required: false
default: type=gha
description: Refer to build-push-action for usage
cache-to:
required: false
default: ''
description: Refer to build-push-action for usage
outputs:
tag:
description: Tag of the newly built image
value: ${{ steps.tag.outputs.tag }}
runs:
using: composite
steps:
- name: Set variables
shell: bash
# Avoid using ${{ github.event.* }} because it's unavailable during scheduled runs
run: |
echo "TAG=$GITHUB_REF_NAME:latest" >> $GITHUB_ENV
echo "REPO=$(cut -d / -f2 <<< ${{ github.repository }})" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v1
- name: Build
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: ${{ env.TAG }}
cache-from: ${{ inputs.cache-from }}
cache-to: ${{ inputs.cache-to }}
build-args: PROD_ASSETS=1
- name: Add tag alias for compose
id: tag
shell: bash
run: |
# The weird ",," syntax forces lowercase
docker tag $TAG ${REPO,,}_${{ inputs.service }}:latest
echo "::set-output name=tag::$TAG"