Skip to content

Commit

Permalink
TMP: push artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Jun 26, 2024
1 parent b0bf784 commit 9f23d67
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
53 changes: 39 additions & 14 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ runs:
version: latest
buildkitd-flags: --debug

# Login to a registry to push the image
- name: Login to Container Registry
# Only login if we are pushing the image
if: ${{ inputs.push == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Docker Image
id: image
shell: bash
Expand Down Expand Up @@ -100,15 +90,50 @@ runs:
cat $GITHUB_OUTPUT
- name: Tar file
id: tar
shell: bash
run: |
echo "path=/tmp/${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT
- name: Build Image
id: build
uses: docker/bake-action@v4
env:
DOCKER_TAG: ${{ steps.tag.outputs.tag }}
with:
targets: app
push: ${{ inputs.push }}
load: ${{ inputs.push == 'false' }}
set: |
*.cache-from=type=registry,ref=${{ steps.tag.outputs.tag_cache }}
*.cache-to=type=registry,ref=${{ steps.tag.outputs.tag_cache }},mode=max,compression-level=9,force-compression=true,ignore-error=true
*.output=type=docker,dest=${{ steps.tar.outputs.path }}
- name: Get image digest
id: digest
shell: bash
run: |
echo '${{ steps.build.outputs.metadata }}' > metadata.json
echo "digest=$(cat metadata.json | jq -r '.app."containerimage.digest"')" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.version }}
path: ${{ steps.tar.outputs.path }}
retention-days: 1
compression-level: 9
overwrite: true

- name: Login to Container Registry
if: inputs.push == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Push Image
if: inputs.push == 'true'
shell: bash
run: |
docker load < ${{ steps.tar.outputs.path }}
docker image push --all-tags ${{ steps.image.outputs.image }}
25 changes: 24 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,41 @@ jobs:
build:
runs-on: ubuntu-latest

outputs:
version: ${{ steps.build.outputs.image_version }}

steps:
- uses: actions/checkout@v4

- id: context
uses: ./.github/actions/context

- uses: ./.github/actions/build
id: build
with:
push: true
push: ${{ steps.context.outputs.is_fork == 'false' }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
node_env: production
latest: ${{ steps.context.outputs.is_release_master }}

download:
runs-on: ubuntu-latest
needs: [build]

steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.version }}
path: /tmp/

- name: Load image
shell: bash
run: |
docker load < /tmp/${{ needs.build.outputs.version }}.tar
docker image ls

0 comments on commit 9f23d67

Please sign in to comment.