Skip to content

Commit

Permalink
✅ Check deployment in release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshix-1 committed Mar 31, 2024
1 parent c36c8b7 commit 21a5251
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 26 deletions.
42 changes: 42 additions & 0 deletions .github/actions/check_deployment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Check deployment
description: Check deployment
inputs:
version:
description: The version to check for
required: true
origin:
description: The origin of the deployment
required: true
runs:
using: composite
steps:
- name: Check deployment
shell: python
run: |
from json import loads
from sys import exit, stderr
from time import sleep
from traceback import print_exc
from urllib.request import urlopen
REQUEST_URL="${{ inputs.origin }}/api/version"
VERSION="${{ inputs.version }}"
print("REQUEST_URL =", REQUEST_URL, file=stderr)
print("VERSION =", VERSION, file=stderr)
def get_running_version():
try:
json = urlopen(REQUEST_URL).read()
return loads(json)["version"]
except Exception:
print_exc(1)
for i in range(10):
sleep(i)
version = get_running_version()
if version == VERSION:
print(version)
exit(0)
print(i, "failed, got", version, file=stderr)
exit(1)
30 changes: 4 additions & 26 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,32 +209,10 @@ jobs:
curl -sSf -T *.whl https://asozial.org/api/update/ \
-H "Authorization: ${{ secrets.UPDATE_API_SECRET }}"
- name: Check deployment
shell: python
run: |
from json import loads
from sys import exit, stderr
from time import sleep
from traceback import print_exc
from urllib.request import urlopen
REQUEST_URL="https://asozial.org/api/version"
VERSION="${{ needs.test-wheel.outputs.version }}"
def get_running_version():
try:
json = urlopen(REQUEST_URL).read()
return loads(json)["version"]
except Exception:
print_exc(1)
for i in range(10):
sleep(i)
version = get_running_version()
if version == VERSION:
print(version)
exit(0)
print(i, version, "!=", VERSION, file=stderr)
exit(1)
uses: ./.github/actions/check_deployment
with:
origin: https://asozial.org
version: ${{ needs.test-wheel.outputs.version }}

github-pages:
name: GitHub Pages
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
python-version:
- 3.12
- 3.13
outputs:
version: ${{ steps.get-version.outputs.an-website-version }}
steps:
- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -74,6 +76,10 @@ jobs:
- name: Test starting
timeout-minutes: 1
run: python -m an_website -c
- name: Get version
id: get-version
timeout-minutes: 1
run: echo "an-website-version=$(python -c 'print(__import__("an_website").VERSION)')" >> "$GITHUB_OUTPUT"

tests:
name: Run tests
Expand Down Expand Up @@ -284,6 +290,11 @@ jobs:
run: |
curl -sSf -T *.whl https://asozial.org/api/update/ \
-H "Authorization: ${{ secrets.UPDATE_API_SECRET }}"
- name: Check deployment
uses: ./.github/actions/check_deployment
with:
origin: https://asozial.org
version: ${{ needs.test-wheel.outputs.version }}

github-pages:
name: GitHub Pages
Expand Down

0 comments on commit 21a5251

Please sign in to comment.