Skip to content

Commit cc58de0

Browse files
committed
Build docker images on github actions
1 parent cb3dc75 commit cc58de0

File tree

4 files changed

+48
-53
lines changed

4 files changed

+48
-53
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44

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

Dockerfile

Lines changed: 2 additions & 2 deletions
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

cloudbuild.yaml

Lines changed: 0 additions & 48 deletions
This file was deleted.

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Preview.MixProject do
55
[
66
app: :preview,
77
version: "0.1.0",
8-
elixir: "~> 1.17",
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)