Skip to content

Commit

Permalink
Make it easier to see what's deployed (#816)
Browse files Browse the repository at this point in the history
* ci: tag the last deployed commit, for auditability

* build: add git ref to footer for debugging
  • Loading branch information
MatMoore authored Sep 11, 2024
1 parent 4ed4ca6 commit f807630
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/deploy-staged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
slack_alert_webhook: ${{ secrets.SLACK_ALERT_WEBHOOK }}
azure_client_secret: ${{ secrets.AZURE_CLIENT_SECRET }}

prepare-release:
name: Prepare a draft release (to be published manually)
post-deploy:
name: "Post-deploy admin"
needs: deploy-prod
runs-on: ubuntu-latest
env:
Expand All @@ -96,5 +96,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Generate a draft release
run: gh release create --generate-notes --latest --draft ${{ github.sha }} --title "Release candidate (${{github.sha}})"
- name: Generate a draft release (to be published manually)
run: gh release create --generate-notes --latest --draft ${{ github.sha }} --title "Release candidate"

- name: Update last-deployed tag
run: |
git tag -f last-deployed
git push --tags
1 change: 1 addition & 0 deletions .github/workflows/reusable-push-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
ENV: ${{ inputs.env }}
CATALOGUE_URL: ${{ vars.CATALOGUE_URL }}
DEBUG: ${{ vars.DEBUG }}
GIT_REF: ${{ github.sha }}
DJANGO_ALLOWED_HOSTS: ${{ vars.DJANGO_ALLOWED_HOSTS }}
CSRF_TRUSTED_ORIGINS: ${{ vars.CSRF_TRUSTED_ORIGINS }}
DJANGO_LOG_LEVEL: ${{ vars.DJANGO_LOG_LEVEL }}
Expand Down
1 change: 1 addition & 0 deletions core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ def analytics(request) -> dict[str, Any]:
return {
"ENABLE_ANALYTICS": settings.ENABLE_ANALYTICS,
"ANALYTICS_ID": settings.ANALYTICS_ID,
"GIT_REF": settings.GIT_REF,
}
2 changes: 2 additions & 0 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,5 @@
CSRF_COOKIE_SECURE = True
LANGUAGE_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True

GIT_REF = os.environ.get("GIT_REF", "unknown")
2 changes: 2 additions & 0 deletions deployments/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ spec:
value: "${CATALOGUE_URL}"
- name: DEBUG
value: "${DEBUG}"
- name: GIT_REF
value: "${GIT_REF}"
- name: DJANGO_ALLOWED_HOSTS
value: "${DJANGO_ALLOWED_HOSTS}"
- name: DJANGO_LOG_LEVEL
Expand Down
3 changes: 3 additions & 0 deletions templates/base/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ <h2 class="govuk-visually-hidden">{% translate "Support links" %}</h2>
{% endblocktranslate %}
</div>
</div>
<p class="govuk-body govuk-body-s">
Find MoJ Data version {{ GIT_REF}}{% if GIT_REF != 'unknown' %} (<a href="https://github.com/ministryofjustice/find-moj-data/tree/{{GIT_REF}}">view source</a>){% endif %}
</p>
</div>
</footer>

0 comments on commit f807630

Please sign in to comment.