|
1 | 1 | name: 'Docker Build'
|
2 | 2 | description: 'Builds docker image'
|
3 | 3 | inputs:
|
4 |
| - push: |
5 |
| - required: true |
6 |
| - description: "Build and push image to registry (cannot be used together with load)" |
7 |
| - default: "false" |
8 |
| - password: |
9 |
| - required: false |
10 |
| - description: "Password for the registry" |
11 |
| - username: |
12 |
| - required: false |
13 |
| - description: "Username for the registry" |
14 | 4 | node_env:
|
15 | 5 | required: false
|
16 | 6 | description: "Node environment"
|
@@ -46,28 +36,11 @@ runs:
|
46 | 36 | version: latest
|
47 | 37 | buildkitd-flags: --debug
|
48 | 38 |
|
49 |
| - # Login to a registry to push the image |
50 |
| - - name: Login to Container Registry |
51 |
| - # Only login if we are pushing the image |
52 |
| - if: ${{ inputs.push == 'true' }} |
53 |
| - uses: docker/login-action@v3 |
54 |
| - with: |
55 |
| - registry: ghcr.io |
56 |
| - username: ${{ inputs.username }} |
57 |
| - password: ${{ inputs.password }} |
58 |
| - |
59 | 39 | - name: Docker Image
|
60 | 40 | id: image
|
61 | 41 | shell: bash
|
62 | 42 | run: |
|
63 |
| - registry="ghcr.io" |
64 |
| - repository="${{ github.repository }}" |
65 |
| - image="$registry/$repository" |
66 |
| -
|
67 |
| - echo "registry=$registry" >> $GITHUB_OUTPUT |
68 |
| - echo "repository=$repository" >> $GITHUB_OUTPUT |
69 |
| - echo "image=$image" >> $GITHUB_OUTPUT |
70 |
| -
|
| 43 | + echo "image=${{ github.repository }}" >> $GITHUB_OUTPUT |
71 | 44 | cat $GITHUB_OUTPUT
|
72 | 45 |
|
73 | 46 | - name: Docker meta
|
@@ -100,15 +73,35 @@ runs:
|
100 | 73 |
|
101 | 74 | cat $GITHUB_OUTPUT
|
102 | 75 |
|
| 76 | + - name: Tar file |
| 77 | + id: tar |
| 78 | + shell: bash |
| 79 | + run: | |
| 80 | + echo "path=/tmp/${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT |
| 81 | +
|
103 | 82 | - name: Build Image
|
104 | 83 | id: build
|
105 | 84 | uses: docker/bake-action@v4
|
106 | 85 | env:
|
107 | 86 | DOCKER_TAG: ${{ steps.tag.outputs.tag }}
|
108 | 87 | with:
|
109 | 88 | targets: app
|
110 |
| - push: ${{ inputs.push }} |
111 |
| - load: ${{ inputs.push == 'false' }} |
112 | 89 | set: |
|
113 |
| - *.cache-from=type=registry,ref=${{ steps.tag.outputs.tag_cache }} |
114 |
| - *.cache-to=type=registry,ref=${{ steps.tag.outputs.tag_cache }},mode=max,compression-level=9,force-compression=true,ignore-error=true |
| 90 | + *.output=type=docker,dest=${{ steps.tar.outputs.path }} |
| 91 | +
|
| 92 | + - name: Get image digest |
| 93 | + id: digest |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + echo '${{ steps.build.outputs.metadata }}' > metadata.json |
| 97 | + echo "digest=$(cat metadata.json | jq -r '.app."containerimage.digest"')" >> $GITHUB_OUTPUT |
| 98 | + cat $GITHUB_OUTPUT |
| 99 | +
|
| 100 | + - name: Upload artifact |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: ${{ steps.meta.outputs.version }} |
| 104 | + path: ${{ steps.tar.outputs.path }} |
| 105 | + retention-days: 1 |
| 106 | + compression-level: 9 |
| 107 | + overwrite: true |
0 commit comments