-
Notifications
You must be signed in to change notification settings - Fork 5
/
action.yml
62 lines (55 loc) · 1.85 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
name: DigitalOcean Docker Image Publish
description: Publish a Docker image to Digital Ocean's Container Registry
branding:
icon: 'upload-cloud'
color: 'blue'
inputs:
image_path:
description: Image path in the format registry-name/image-name
required: true
sha_size:
description: Number of characters from the commit SHA
required: false
default: '8'
dockerfile:
description: The path + name of the Dockerfile you want to build (-f flag)
required: false
default: 'Dockerfile'
docker_build_context:
description: The docker build context (usually '.')
required: false
default: '.'
outputs:
image_url:
description: 'Url of the uploaded image with the SHA tag'
value: ${{ steps.image_tags.outputs.sha }}
image_latest_url:
description: 'Url of the uploaded image with the latest tag'
value: ${{ steps.image_tags.outputs.latest }}
runs:
using: composite
steps:
- name: Generate Image Url
id: image_url
shell: bash
run: echo "::set-output name=value::registry.digitalocean.com/${{ inputs.image_path }}"
- name: Generate Tagged Urls
id: image_tags
shell: bash
run: |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-${{ inputs.sha_size }})
echo "::set-output name=sha::${{ steps.image_url.outputs.value }}:$SHORT_SHA"
echo "::set-output name=latest::${{ steps.image_url.outputs.value }}:latest"
- name: Build image
shell: bash
run: >
docker build ${{ inputs.docker_build_context }}
-f ${{ inputs.dockerfile }}
-t ${{ steps.image_tags.outputs.sha }}
-t ${{ steps.image_tags.outputs.latest }}
- name: Login to registry
shell: bash
run: doctl registry login --expiry-seconds 600
- name: Upload image to registry
shell: bash
run: docker push -a ${{ steps.image_url.outputs.value }}