Skip to content

Commit

Permalink
Merge pull request #18 from AndrewChubatiuk/frontend-build
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
AndrewChubatiuk authored Mar 9, 2024
2 parents 444f7e6 + f7c68ba commit a2819ec
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions .github/workflows/preview-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ on:
- master

env:
DOCKER_REPO: redash/redash
PREVIEW_DOCKER_REPO: redash/preview
DOCKER_REPO: redash

jobs:
build-skip-check:
Expand All @@ -22,7 +21,7 @@ jobs:
- name: Skip?
id: skip-check
run: |
if [[ "${{ secrets.DOCKER_USER }}" == '' ]]; then
if [[ "${{ vars.DOCKER_USER }}" == '' ]]; then
echo 'Docker user is empty. Skipping build+push'
echo skip=true >> "$GITHUB_OUTPUT"
elif [[ "${{ secrets.DOCKER_PASS }}" == '' ]]; then
Expand All @@ -40,6 +39,7 @@ jobs:
- build-skip-check
outputs:
version: ${{ steps.version.outputs.VERSION_TAG }}
repo: ${{ steps.version.outputs.DOCKER_REPO }}
if: needs.build-skip-check.outputs.skip == 'false'
strategy:
fail-fast: false
Expand All @@ -64,7 +64,7 @@ jobs:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Set version
id: version
Expand All @@ -80,9 +80,7 @@ jobs:
echo "SCOPE=${platform//\//-}" >> $GITHUB_ENV
if [[ "${{ vars.DOCKER_REPO }}" != "" ]]; then
echo "DOCKER_REPO=${{ vars.DOCKER_REPO }}" >> $GITHUB_ENV
fi
if [[ "${{ vars.PREVIEW_DOCKER_REPO }}" != "" ]]; then
echo "PREVIEW_DOCKER_REPO=${{ vars.PREVIEW_DOCKER_REPO }}" >> $GITHUB_ENV
echo "DOCKER_REPO=${{ vars.DOCKER_REPO }}" >> $GITHUB_OUTPUT
fi
- name: Build and push preview image to Docker Hub
uses: docker/build-push-action@v5
Expand All @@ -93,7 +91,7 @@ jobs:
cache-from: type=gha,scope=${{ env.SCOPE }}
cache-to: type=gha,mode=max,scope=${{ env.SCOPE }}
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ env.DOCKER_REPO }},push-by-digest=true,name-canonical=true,push=true
outputs: type=image,name=${{ env.DOCKER_REPO }}/redash,push-by-digest=true,name-canonical=true,push=true
build-args: |
FRONTEND_BUILD_MODE=1
env:
Expand Down Expand Up @@ -130,23 +128,24 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REPO }}
images: ${{ needs.build-docker-image.outputs.repo }}/redash
tags: preview
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKER_REPO }}@sha256:%s ' *)
$(printf '${{ needs.build-docker-image.outputs.repo }}/redash@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DOCKER_REPO }}:${{ steps.meta.outputs.version }}
- name: Push image ${{ env.PREVIEW_DOCKER_REPO }} image
REDASH_IMAGE="${{ needs.build-docker-image.outputs.repo }}/redash:${{ steps.meta.outputs.version }}"
docker buildx imagetools inspect $REDASH_IMAGE
- name: Push image ${{ needs.build-docker-image.outputs.repo }}/preview image
run: |
docker buildx imagetools create \
--tag ${{ env.PREVIEW_DOCKER_REPO }}:${{ needs.build-docker-image.outputs.version }} \
${{ env.DOCKER_REPO }}:preview
REDASH_IMAGE="${{ needs.build-docker-image.outputs.repo }}/redash:preview"
PREVIEW_IMAGE="${{ needs.build-docker-image.outputs.repo }}/preview:${{ needs.build-docker-image.outputs.version }}"
docker buildx imagetools create --tag $PREVIEW_IMAGE $REDASH_IMAGE

0 comments on commit a2819ec

Please sign in to comment.