-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
65 lines (60 loc) · 2.12 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
name: "Build Image and Run Command"
description: "Build an image and run the given command"
inputs:
target:
description: "Sets the target stage to build"
required: true
run:
description: "Run command in container"
required: false
options:
description: "Options"
required: false
cache-to:
description: "List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir)"
required: false
secrets:
description: "List of secrets to expose to the build (e.g., key=string, GIT_AUTH_TOKEN=mytoken)"
required: false
runs:
using: "composite"
steps:
- name: Repo metadata
id: repo
uses: actions/[email protected]
with:
script: |
const repo = await github.rest.repos.get(context.repo)
return repo.data
- name: Prepare
id: prep
shell: bash
run: |
echo "docker-image=ghcr.io/${{ github.event.repository.full_name }}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Build image
id: docker-build
uses: docker/[email protected]
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
labels: |
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).clone_url }}
org.opencontainers.image.revision=${{ github.sha }}
cache-from: type=gha
cache-to: ${{ inputs.cache-to }}
target: ${{ inputs.target }}
load: ${{ !!inputs.run }}
secrets: ${{ inputs.secrets }}
- name: Run command
if: ${{ inputs.run }}
uses: addnab/docker-run-action@v3
with:
image: ${{ steps.prep.outputs.docker-image }}:@${{ steps.docker-build.outputs.digest }}
run: ${{ inputs.run }}
options: ${{ inputs.options }}