diff --git a/.github/workflows/push-frontend-image-docker.yml b/.github/workflows/push-frontend-image-docker.yml new file mode 100644 index 000000000..1b948f19b --- /dev/null +++ b/.github/workflows/push-frontend-image-docker.yml @@ -0,0 +1,130 @@ +name: Push frontend to Dockerhub + +on: [workflow_dispatch] + +jobs: + # backend-image: + # name: Build backend image + # runs-on: ubuntu-latest + + # steps: + # - name: โ˜๏ธ Checkout source + # uses: actions/checkout@v3 + # - name: Save commit hashes for tag + # id: commit + # uses: pr-mpt/actions-commit-hash@v2 + # - name: ๐Ÿ”ง Set up QEMU + # uses: docker/setup-qemu-action@v2 + # - name: ๐Ÿ”ง Set up Docker Buildx + # uses: docker/setup-buildx-action@v2 + # - name: Cache Docker layers + # uses: actions/cache@v3 + # with: + # path: /tmp/.buildx-cache + # key: ${{ runner.os }}-buildx-${{ github.sha }} + # restore-keys: | + # ${{ runner.os }}-buildx- + # - name: ๐Ÿ‹ Login to Docker Hub + # uses: docker/login-action@v2 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + # - name: ๐Ÿ“ฆ Build backend and export to Docker + # uses: docker/build-push-action@v3 + # with: + # load: true + # context: backend + # tags: infisical/backend:test + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - name: โป Spawn backend container and dependencies + # run: | + # docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull + # - name: ๐Ÿงช Test backend image + # run: | + # ./.github/resources/healthcheck.sh infisical-backend-test + # - name: โป Shut down backend container and dependencies + # run: | + # docker compose -f .github/resources/docker-compose.be-test.yml down + # - name: ๐Ÿ—๏ธ Build backend and push + # uses: docker/build-push-action@v3 + # with: + # push: true + # context: backend + # tags: infisical/backend:${{ steps.commit.outputs.short }}, + # infisical/backend:latest + # platforms: linux/amd64,linux/arm64 + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - # Temp fix + # # https://github.com/docker/build-push-action/issues/252 + # # https://github.com/moby/buildkit/issues/1896 + # name: Move cache + # run: | + # rm -rf /tmp/.buildx-cache + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + frontend-image: + name: Build frontend image + runs-on: ubuntu-latest + + steps: + - name: โ˜๏ธ Checkout source + uses: actions/checkout@v3 + - name: Save commit hashes for tag + id: commit + uses: pr-mpt/actions-commit-hash@v2 + - name: ๐Ÿ”ง Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: ๐Ÿ”ง Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: ๐Ÿ‹ Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: ๐Ÿ“ฆ Build frontend and export to Docker + uses: docker/build-push-action@v3 + with: + load: true + context: frontend + tags: infisical/frontend:test + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - name: โป Spawn frontend container + run: | + docker run -d --rm --name infisical-frontend-test infisical/frontend:test + - name: ๐Ÿงช Test frontend image + run: | + ./.github/resources/healthcheck.sh infisical-frontend-test + - name: โป Shut down frontend container + run: | + docker stop infisical-frontend-test + - name: ๐Ÿ—๏ธ Build frontend and push + uses: docker/build-push-action@v3 + with: + push: true + context: frontend + tags: infisical/frontend:${{ steps.commit.outputs.short }}, + infisical/frontend:latest + platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache