-
Notifications
You must be signed in to change notification settings - Fork 206
/
action.yml
73 lines (73 loc) · 2.02 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
72
73
name: 'Push'
inputs:
head_sha:
required: true
artifact_name:
required: true
artifact_image_file:
required: true
artifact_image_name:
required: true
image:
required: true
default: ghcr.io/${{ github.repository }}:latest
registry:
required: true
default: ghcr.io
username:
required: true
default: ${{ github.actor }}
password:
required: true
default: ${{ github.token }}
runs:
using: "composite"
steps:
-
uses: actions/download-artifact@v2
with:
name: ${{ inputs.artifact_name }}
path: /tmp/
-
shell: bash
run: docker load -i /tmp/${{ inputs.artifact_image_file }}
-
id: image_parts
shell: bash
run: |
IMAGE_TAGLESS=$(echo ${{ inputs.image }} | cut -d':' -f1)
IMAGE_REPO=$(echo $IMAGE_TAGLESS | cut -d'/' -f2,3)
IMAGE_TAG=$(echo ${{ inputs.image }} | cut -d':' -f2)
echo "::set-output name=repo::$IMAGE_REPO"
echo "::set-output name=tag::$IMAGE_TAG"
-
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
-
shell: bash
run: echo "IMAGE_URL=https://${{ inputs.image }}" >> $GITHUB_ENV
-
if: ${{ inputs.registry == 'docker.io' }}
shell: bash
run: |
echo "IMAGE_URL=https://hub.docker.com/r/${{ steps.image_parts.outputs.repo }}/tags?name=${{ steps.image_parts.outputs.tag }}" >> $GITHUB_ENV
-
shell: bash
run: |
docker push ${{ inputs.image }}
-
uses: actions/github-script@v5
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ inputs.head_sha }}',
state: 'success',
context: context.workflow,
target_url: '${{ env.IMAGE_URL }}',
description: '${{ inputs.image }}',
});