close
Skip to content

Commit 0c8d300

Browse files
authored
Merge pull request #7653 from escattone/fix-dockerflow-version-3144
fix dockerflow __version__ endpoint
2 parents 4fe3382 + ca8e506 commit 0c8d300

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

‎.github/workflows/build-and-push.yml‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,6 @@ jobs:
4444
REF_ID: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref }}
4545
run: echo "REF_ID=$REF_ID" >> $GITHUB_ENV
4646

47-
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
48-
with:
49-
persist-credentials: false
50-
- name: Create version.json
51-
run: |
52-
# create a version.json per
53-
# https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md
54-
printf '{"commit":"%s","version":"%s","source":"%s","build":"%s"}\n' \
55-
"$GITHUB_SHA" \
56-
"$GITHUB_REF_NAME" \
57-
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
58-
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > version.json
59-
6047
- id: checkout_application_repo
6148
name: checkout application repo
6249
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
@@ -113,6 +100,19 @@ jobs:
113100
username: oauth2accesstoken
114101
password: ${{ steps.gcp_auth.outputs.access_token }}
115102

103+
- name: Create version.json
104+
run: |
105+
# create a version.json per
106+
# https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md
107+
# Must run AFTER the final checkout: actions/checkout defaults to
108+
# clean=true, which `git clean`s this untracked file. Creating it here,
109+
# right before the build, ensures it lands in the image via `COPY . .`.
110+
printf '{"commit":"%s","version":"%s","source":"%s","build":"%s"}\n' \
111+
"$GITHUB_SHA" \
112+
"$GITHUB_REF_NAME" \
113+
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
114+
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > version.json
115+
116116
- id: build_and_push
117117
name: Build and push image
118118
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5

‎kitsune/settings.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
# Repository directory.
3333
ROOT = os.path.dirname(os.path.dirname(__file__))
3434

35+
# Dockerflow's `/__version__` view reads `version.json` from `settings.BASE_DIR`
36+
# (see dockerflow.django.views.version). CI writes that file to the repo root,
37+
# which is `ROOT`, so point BASE_DIR there. Without this the view raises
38+
# AttributeError and `/__version__` returns a 500.
39+
BASE_DIR = ROOT
40+
3541
# Django project directory.
3642
PROJECT_ROOT = os.path.dirname(__file__)
3743

0 commit comments

Comments
 (0)