From 418cf01fd95902765c2ae604b7284e292f0e8ba0 Mon Sep 17 00:00:00 2001 From: Irori235 Date: Thu, 19 Oct 2023 16:22:54 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20Github=20Actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yaml | 44 ++++++++++++++++++++++++++++++++++++ Dockerfile | 1 - 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..a18d0d4 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,44 @@ +name: Build docker image and push to Artifact Registry + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - name: Authenticate to Google Cloud + id: auth + uses: google-github-actions/auth@v1 + with: + token_format: access_token + workload_identity_provider: "projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/${{ secrets.GOOGLE_WID_POOL_ID }}/providers/${{ secrets.GOOGLE_WID_PROVIDER_ID }}" + service_account: ${{ secrets.GOOGLE_SA_EMAIL }} + access_token_lifetime: 300 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GAR + uses: docker/login-action@v3 + with: + registry: asia-northeast1-docker.pkg.dev + username: oauth2accesstoken + password: ${{ steps.auth.outputs.access_token }} + - name: Create Tag SHA + id: create-tag-sha + run: | + echo ${{ github.sha }} | cut -c 1-7 | awk '{print "sha="$0}' >> $GITHUB_OUTPUT + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + asia-northeast1-docker.pkg.dev/irori-gcloud/irori-dev/portfolio:${{ steps.create-tag-sha.outputs.sha }} + asia-northeast1-docker.pkg.dev/irori-gcloud/irori-dev/portfolio:latest diff --git a/Dockerfile b/Dockerfile index 925809c..a3ad8c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,6 @@ WORKDIR /app # Copy artifacts COPY ./next.config.js . -COPY ./.next ./.next # Copy node_modules COPY --from=base /app/node_modules ./node_modules