Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule publishing retries #60

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ on:
branches:
- main

schedule:
# Run hourly; will only do work if the last job succeeded
- cron: '0 * * * *'


permissions:
contents: read

Expand All @@ -35,26 +40,60 @@ jobs:
steps:
- uses: actions/checkout@v4

# Only runs during the scheduled job
# The rest of the workflow will be skipped during scheduled runs unless the last run failed
- name: Check status of last workflow run
id: check_last_run
if: github.event.schedule
run: |
WORKFLOW_ID=$( \
curl \
--silent \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }} \
| jq -r .workflow_id \
)

CONCLUSION=$( \
curl \
--silent \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
"${{ github.api_url }}/repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/runs?per_page=1&status=completed&branch=main" \
| jq -r .workflow_runs[0].conclusion \
)

echo "conclusion=$CONCLUSION"
echo "conclusion=$CONCLUSION" >> $GITHUB_OUTPUT

# Implementation based on https://github.com/MercymeIlya/last-workflow-status

- name: Set up Poetry
if: steps.check_last_run.outcome == 'skipped' || steps.check_last_run.outputs.conclusion == 'failure'
run: |
pipx install poetry==${{ env.POETRY_VERSION }}

- name: Set up Python ${{ matrix.python-version }}
if: steps.check_last_run.outcome == 'skipped' || steps.check_last_run.outputs.conclusion == 'failure'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: poetry

- name: Install zsh
if: steps.check_last_run.outcome == 'skipped' || steps.check_last_run.outputs.conclusion == 'failure'
run: |
sudo apt-get update
sudo apt-get install zsh

- name: Install packages
if: steps.check_last_run.outcome == 'skipped' || steps.check_last_run.outputs.conclusion == 'failure'
run: |
poetry install

- name: Collect scenarios
if: steps.check_last_run.outcome == 'skipped' || steps.check_last_run.outputs.conclusion == 'failure'
run: |
scenarios=(scenarios/**/*.json)

Expand All @@ -70,10 +109,12 @@ jobs:
shell: zsh {0}

- name: View scenarios
if: steps.check_last_run.outcome == 'skipped' || steps.check_last_run.outputs.conclusion == 'failure'
run: |
poetry run packse view $SCENARIOS

- name: Build scenarios
if: steps.check_last_run.outcome == 'skipped' || steps.check_last_run.outputs.conclusion == 'failure'
run: |
poetry run packse build $SCENARIOS

Expand All @@ -90,7 +131,7 @@ jobs:
poetry run packse index down

- name: Publish scenarios [test pypi]
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' && (steps.check_last_run.outcome == 'skipped' || steps.check_last_run.outputs.conclusion == 'failure')
env:
PACKSE_PUBLISH_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
Expand Down