Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Add a simple script for getting a sanitized commit message (#2115)
Madison Swain-Bowden3c0ebee3d1b6
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.ymlindex f21e425ec..e69ebfb4b 100644--- a/.github/workflows/ci_cd.yml+++ b/.github/workflows/ci_cd.yml@@ -882,6 +882,17 @@ jobs:- get-image-tag- publish-imagessteps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Get commit message+ id: commit+ env:+ COMMIT_MESSAGE: ${{ github.event.head_commit.message }}+ PYTHONPATH: ${{ github.workspace }}/automations/python+ working-directory: automations/python/workflows+ run: python get_commit_message.py+- name: Deploy staging frontenduses: felixp8/[email protected]with:@@ -893,7 +904,7 @@ jobs:{"actor": "${{ github.actor }}","tag": "${{ needs.get-image-tag.outputs.image_tag }}",- "run_name": "${{ github.event.head_commit.message }}"+ "run_name": "${{ steps.commit.outputs.commit_message }}"}wait_time: 60 # check every minutemax_time: 1800 # allow up to 30 minutes for a deployment@@ -911,6 +922,17 @@ jobs:- get-image-tag- publish-imagessteps:+ - name: Checkout repository+ uses: actions/checkout@v3++ - name: Get commit message+ id: commit+ env:+ COMMIT_MESSAGE: ${{ github.event.head_commit.message }}+ PYTHONPATH: ${{ github.workspace }}/automations/python+ working-directory: automations/python/workflows+ run: python get_commit_message.py+- name: Deploy staging APIuses: felixp8/[email protected]with:@@ -922,7 +944,7 @@ jobs:{"actor": "${{ github.actor }}","tag": "${{ needs.get-image-tag.outputs.image_tag }}",- "run_name": "${{ github.event.head_commit.message }}"+ "run_name": "${{ steps.commit.outputs.commit_message }}"}wait_time: 60 # check every minutemax_time: 1800 # allow up to 30 minutes for a deploymentdiff --git a/automations/python/workflows/get_commit_message.py b/automations/python/workflows/get_commit_message.pynew file mode 100644index 000000000..ddfe9373b--- /dev/null+++ b/automations/python/workflows/get_commit_message.py@@ -0,0 +1,24 @@+import os++from shared.actions import write_to_github_output+++def main() -> None:+ """+ Get the COMMIT_MESSAGE environment variable and convert it into a single+ line of text, with quote characters escaped.++ This is necessary because GitHub Actions does not provide any functions for string+ manipulation and interpolating this wholesale into the JSON client payload+ will cause the workflow to fail since it's not valid JSON.+ """+ commit_message = os.environ["COMMIT_MESSAGE"]+ # Split newlines+ message = commit_message.split("\n", 1)[0]+ # Escape quotes+ message = message.replace('"', '\\"')+ write_to_github_output([f"commit_message={message}"])+++if __name__ == "__main__":+ main()