From 67d816a4fcfcd852b64fcdefe60b213b02dc0b98 Mon Sep 17 00:00:00 2001 From: Tsukasa Arima Date: Wed, 22 May 2024 12:28:50 +0000 Subject: [PATCH] add github action --- .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e2e8756 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +--- +name: Release +on: [push] +jobs: + release: + runs-on: ubuntu-22.04 + permissions: + packages: write + contents: read + env: + CONTAINER_REGISTRY: ghcr.io/pyar6329/postgres + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Github Docker Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Test Building Dockerfile + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64,linux/arm64 + context: . + file: ./Dockerfile + push: false + cache-from: type=gha + cache-to: type=gha,mode=max + + # - name: Get Docker image tag for Release + # id: release_tag + # if: startsWith(github.ref, 'refs/tags/') + # run: | + # echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT + + - name: Get Docker image tag for Release + id: release_tag + run: | + echo "tag=wip-0.0.1" >> $GITHUB_OUTPUT + + - name: Build PostgreSQL image and push it to GItHub Container Registry + uses: docker/build-push-action@v5 + # if: startsWith(github.ref, 'refs/tags/') + env: + IMAGE_TAG: release-${{ steps.release_tag.outputs.tag }} + with: + platforms: linux/amd64,linux/arm64 + context: . + file: ./Dockerfile + push: true + tags: | + ${{ env.CONTAINER_REGISTRY }}:${{ env.IMAGE_TAG }} + ${{ env.CONTAINER_REGISTRY }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max