Skip to content

Commit 9d63d2a

Browse files
authored
Build docker images on github actions (#104)
1 parent 32e3e94 commit 9d63d2a

File tree

4 files changed

+58
-53
lines changed

4 files changed

+58
-53
lines changed

Diff for: .github/workflows/main.yml

+55-2
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,70 @@ jobs:
66
test:
77
env:
88
MIX_ENV: test
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-24.04
1010
steps:
1111
- uses: actions/checkout@v2
1212

1313
- uses: erlef/setup-beam@v1
1414
with:
1515
otp-version: 27.2
16-
elixir-version: 1.17.3
16+
elixir-version: 1.18.1
1717

1818
- run: mix deps.get
1919
- run: mix format --check-formatted
2020
- run: mix deps.unlock --check-unused
2121
- run: MIX_ENV=test mix compile --warnings-as-errors
2222
- run: mix test
23+
24+
docker:
25+
name: Docker
26+
runs-on: ubuntu-24.04
27+
28+
permissions:
29+
contents: 'read'
30+
id-token: 'write'
31+
32+
env:
33+
IMAGE_NAME: 'diff'
34+
PROJECT_ID: 'hexpm-prod'
35+
SERVICE_ACCOUNT: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }}
36+
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCLOUD_WORKFLOW_IDENTITY_POOL_PROVIDER }}
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Set short git commit SHA
42+
id: vars
43+
run: |
44+
calculatedSha=$(git rev-parse --short ${{ github.sha }})
45+
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Google auth
51+
id: auth
52+
uses: 'google-github-actions/auth@v2'
53+
if: ${{ github.event_name != 'pull_request' }}
54+
with:
55+
token_format: 'access_token'
56+
project_id: ${{ env.PROJECT_ID }}
57+
service_account: ${{ env.SERVICE_ACCOUNT }}
58+
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
59+
60+
- name: Docker Auth
61+
id: docker-auth
62+
uses: 'docker/login-action@v3'
63+
if: ${{ github.event_name != 'pull_request' }}
64+
with:
65+
registry: gcr.io
66+
username: 'oauth2accesstoken'
67+
password: '${{ steps.auth.outputs.access_token }}'
68+
69+
- name: Build and push
70+
uses: docker/build-push-action@v6
71+
with:
72+
tags: gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHORT_SHA }}
73+
push: ${{ github.event_name != 'pull_request' }}
74+
cache-from: type=gha
75+
cache-to: type=gha,mode=max

Diff for: Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
ARG ELIXIR_VERSION=1.17.3
1+
ARG ELIXIR_VERSION=1.18.1
22
ARG ERLANG_VERSION=27.2
3-
ARG DEBIAN_VERSION=bookworm-20241202-slim
3+
ARG DEBIAN_VERSION=bookworm-20241223-slim
44

55
FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-debian-${DEBIAN_VERSION} AS build
66

Diff for: cloudbuild.yaml

-48
This file was deleted.

Diff for: mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Diff.MixProject do
55
[
66
app: :diff,
77
version: "0.1.0",
8-
elixir: "~> 1.10",
8+
elixir: "~> 1.18",
99
elixirc_paths: elixirc_paths(Mix.env()),
1010
start_permanent: Mix.env() == :prod,
1111
aliases: aliases(),

0 commit comments

Comments
 (0)