Skip to content

Commit a1ac2c5

Browse files
committed
TMP: push artifact
1 parent b0bf784 commit a1ac2c5

File tree

2 files changed

+63
-15
lines changed

2 files changed

+63
-15
lines changed

.github/actions/build/action.yml

+39-14
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ runs:
4646
version: latest
4747
buildkitd-flags: --debug
4848

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-
5949
- name: Docker Image
6050
id: image
6151
shell: bash
@@ -100,15 +90,50 @@ runs:
10090
10191
cat $GITHUB_OUTPUT
10292
93+
- name: Tar file
94+
id: tar
95+
shell: bash
96+
run: |
97+
echo "path=/tmp/${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT
98+
10399
- name: Build Image
104100
id: build
105101
uses: docker/bake-action@v4
106102
env:
107103
DOCKER_TAG: ${{ steps.tag.outputs.tag }}
108104
with:
109105
targets: app
110-
push: ${{ inputs.push }}
111-
load: ${{ inputs.push == 'false' }}
112106
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
107+
*.output=type=docker,dest=${{ steps.tar.outputs.path }}
108+
109+
- name: Get image digest
110+
id: digest
111+
shell: bash
112+
run: |
113+
echo '${{ steps.build.outputs.metadata }}' > metadata.json
114+
echo "digest=$(cat metadata.json | jq -r '.app."containerimage.digest"')" >> $GITHUB_OUTPUT
115+
cat $GITHUB_OUTPUT
116+
117+
- name: Upload artifact
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: ${{ steps.meta.outputs.version }}
121+
path: ${{ steps.tar.outputs.path }}
122+
retention-days: 1
123+
compression-level: 9
124+
overwrite: true
125+
126+
- name: Login to Container Registry
127+
if: inputs.push == 'true'
128+
uses: docker/login-action@v3
129+
with:
130+
registry: ghcr.io
131+
username: ${{ inputs.username }}
132+
password: ${{ inputs.password }}
133+
134+
- name: Push Image
135+
if: inputs.push == 'true'
136+
shell: bash
137+
run: |
138+
docker load < ${{ steps.tar.outputs.path }}
139+
docker image push --all-tags ${{ steps.image.outputs.image }}

.github/workflows/push.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,41 @@ jobs:
1313
build:
1414
runs-on: ubuntu-latest
1515

16+
outputs:
17+
version: ${{ steps.build.outputs.version }}
18+
1619
steps:
1720
- uses: actions/checkout@v4
1821

1922
- id: context
2023
uses: ./.github/actions/context
2124

2225
- uses: ./.github/actions/build
26+
id: build
2327
with:
24-
push: true
28+
push: ${{ steps.context.outputs.is_fork == 'false' }}
2529
username: ${{ github.actor }}
2630
password: ${{ secrets.GITHUB_TOKEN }}
2731
node_env: production
2832
latest: ${{ steps.context.outputs.is_release_master }}
2933

34+
download:
35+
runs-on: ubuntu-latest
36+
needs: [build]
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: actions/download-artifact@v4
42+
with:
43+
name: ${{ needs.build.outputs.version }}
44+
path: /tmp/
45+
46+
- name: Load image
47+
shell: bash
48+
run: |
49+
docker load < /tmp/${{ needs.build.outputs.version }}
50+
docker image ls
51+
52+
3053

0 commit comments

Comments
 (0)