Skip to content

Commit d29bb65

Browse files
committed
WIP: Build docker images on github actions
1 parent b46a791 commit d29bb65

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

Diff for: .github/workflows/main.yml

+53-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ on: [push, pull_request]
55
jobs:
66
test:
77
name: Test
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-24.04
99

1010
steps:
11-
- uses: actions/checkout@v1
11+
- uses: actions/checkout@v4
1212

1313
- name: Install OTP and Elixir
1414
uses: erlef/setup-beam@v1
1515
with:
16-
otp-version: 27.1.2
17-
elixir-version: 1.17.3
16+
otp-version: 27.2
17+
elixir-version: 1.18.1
1818

1919
- name: Install dependencies
2020
run: |
@@ -30,3 +30,52 @@ jobs:
3030
- name: Run tests
3131
run: |
3232
mix test --include typesense
33+
34+
docker:
35+
name: Docker
36+
runs-on: ubuntu-24.04
37+
38+
permissions:
39+
contents: 'read'
40+
id-token: 'write'
41+
42+
env:
43+
IMAGE_NAME: 'hexdocs'
44+
PROJECT_ID: 'hexpm-prod'
45+
SERVICE_ACCOUNT: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }}
46+
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCLOUD_WORKFLOW_IDENTITY_POOL_PROVIDER }}
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Set short git commit SHA
52+
id: vars
53+
run: |
54+
calculatedSha=$(git rev-parse --short ${{ github.sha }})
55+
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
56+
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
60+
- name: Google auth
61+
id: auth
62+
uses: 'google-github-actions/auth@v2'
63+
with:
64+
token_format: 'access_token'
65+
project_id: ${{ env.PROJECT_ID }}
66+
service_account: ${{ env.SERVICE_ACCOUNT }}
67+
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
68+
69+
- name: Docker Auth
70+
id: docker-auth
71+
uses: 'docker/login-action@v1'
72+
with:
73+
registry: gcr.io
74+
username: 'oauth2accesstoken'
75+
password: '${{ steps.auth.outputs.access_token }}'
76+
77+
- name: Build and push
78+
uses: docker/build-push-action@v6
79+
with:
80+
push: ${{ github.event_name != 'pull_request' }}
81+
tags: gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHORT_SHA }}

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

0 commit comments

Comments
 (0)