Skip to content

Commit 6423d74

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

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

Diff for: .github/workflows/main.yml

+49-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,48 @@ 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+
env:
39+
IMAGE_NAME: 'hexdocs'
40+
PROJECT_ID: 'hexpm-prod'
41+
SERVICE_ACCOUNT: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }}
42+
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCLOUD_WORKFLOW_IDENTITY_POOL_PROVIDER }}
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Set short git commit SHA
48+
id: vars
49+
run: |
50+
calculatedSha=$(git rev-parse --short ${{ github.sha }})
51+
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
52+
53+
- name: Set up Docker Buildx
54+
uses: docker/setup-buildx-action@v3
55+
56+
- name: Google auth
57+
id: auth
58+
uses: 'google-github-actions/auth@v2'
59+
with:
60+
token_format: 'access_token'
61+
project_id: ${{ env.PROJECT_ID }}
62+
service_account: ${{ env.SERVICE_ACCOUNT }}
63+
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
64+
65+
- name: Docker Auth
66+
id: docker-auth
67+
uses: 'docker/login-action@v1'
68+
with:
69+
registry: gcr.io
70+
username: 'oauth2accesstoken'
71+
password: '${{ steps.auth.outputs.access_token }}'
72+
73+
- name: Build and push
74+
uses: docker/build-push-action@v6
75+
with:
76+
push: ${{ github.event_name != 'pull_request' }}
77+
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)