diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 002a542..3377487 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,17 +6,70 @@ jobs: test: env: MIX_ENV: test - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v2 - uses: erlef/setup-beam@v1 with: otp-version: 27.2 - elixir-version: 1.17.3 + elixir-version: 1.18.1 - run: mix deps.get - run: mix format --check-formatted - run: mix deps.unlock --check-unused - run: MIX_ENV=test mix compile --warnings-as-errors - run: mix test + + docker: + name: Docker + runs-on: ubuntu-24.04 + + permissions: + contents: 'read' + id-token: 'write' + + env: + IMAGE_NAME: 'diff' + PROJECT_ID: 'hexpm-prod' + SERVICE_ACCOUNT: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }} + WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCLOUD_WORKFLOW_IDENTITY_POOL_PROVIDER }} + + steps: + - uses: actions/checkout@v4 + + - name: Set short git commit SHA + id: vars + run: | + calculatedSha=$(git rev-parse --short ${{ github.sha }}) + echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Google auth + id: auth + uses: 'google-github-actions/auth@v2' + if: ${{ github.event_name != 'pull_request' }} + with: + token_format: 'access_token' + project_id: ${{ env.PROJECT_ID }} + service_account: ${{ env.SERVICE_ACCOUNT }} + workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} + + - name: Docker Auth + id: docker-auth + uses: 'docker/login-action@v3' + if: ${{ github.event_name != 'pull_request' }} + with: + registry: gcr.io + username: 'oauth2accesstoken' + password: '${{ steps.auth.outputs.access_token }}' + + - name: Build and push + uses: docker/build-push-action@v6 + with: + tags: gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHORT_SHA }} + push: ${{ github.event_name != 'pull_request' }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 97e3ec2..15db64d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -ARG ELIXIR_VERSION=1.17.3 +ARG ELIXIR_VERSION=1.18.1 ARG ERLANG_VERSION=27.2 -ARG DEBIAN_VERSION=bookworm-20241202-slim +ARG DEBIAN_VERSION=bookworm-20241223-slim FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-debian-${DEBIAN_VERSION} AS build diff --git a/cloudbuild.yaml b/cloudbuild.yaml deleted file mode 100644 index fd5bd94..0000000 --- a/cloudbuild.yaml +++ /dev/null @@ -1,48 +0,0 @@ -steps: -- name: 'gcr.io/cloud-builders/docker' - args: ['pull', 'gcr.io/$PROJECT_ID/diff-build:latest'] - id: pull-build - waitFor: ['-'] -- name: 'gcr.io/cloud-builders/docker' - args: ['pull', 'gcr.io/$PROJECT_ID/diff:latest'] - id: pull-app - waitFor: ['-'] -- name: 'gcr.io/cloud-builders/docker' - args: - - 'build' - - '-t' - - 'gcr.io/$PROJECT_ID/diff-build:latest' - - '-t' - - 'gcr.io/$PROJECT_ID/diff-build:$SHORT_SHA' - - '--cache-from' - - 'gcr.io/$PROJECT_ID/diff-build:latest' - - '--target' - - 'build' - - '.' - id: build-build - waitFor: ['pull-build'] -- name: 'gcr.io/cloud-builders/docker' - args: - - 'build' - - '-t' - - 'gcr.io/$PROJECT_ID/diff:latest' - - '-t' - - 'gcr.io/$PROJECT_ID/diff:$SHORT_SHA' - - '--cache-from' - - 'gcr.io/$PROJECT_ID/diff-build:latest' - - '--cache-from' - - 'gcr.io/$PROJECT_ID/diff:latest' - - '--target' - - 'app' - - '.' - id: build-app - waitFor: ['build-build', 'pull-app'] - -images: -- 'gcr.io/$PROJECT_ID/diff-build:latest' -- 'gcr.io/$PROJECT_ID/diff:latest' -- 'gcr.io/$PROJECT_ID/diff-build:$SHORT_SHA' -- 'gcr.io/$PROJECT_ID/diff:$SHORT_SHA' - -options: - machineType: 'N1_HIGHCPU_8' diff --git a/mix.exs b/mix.exs index e5a8501..43771a3 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ defmodule Diff.MixProject do [ app: :diff, version: "0.1.0", - elixir: "~> 1.10", + elixir: "~> 1.18", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, aliases: aliases(),