Skip to content

trigger docker reqs workflow (#472) #136

trigger docker reqs workflow (#472)

trigger docker reqs workflow (#472) #136

name: docker-requirements
on:
push:
branches:
- test-ci
workflow_dispatch:
permissions:
pull-requests: write
contents: write
issues: write
jobs:
update:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup environment
uses: ./.github/actions/setup-env
with:
python-version: "3.11"
optional-dependencies: "false"
- name: Update docker requirements
id: update
run: |
pip-compile \
--quiet \
--strip-extras --output-file=requirements-docker.lock \
--extra=all pyproject.toml
NEEDS_UPDATE=$(git diff --quiet && echo 'false' || echo 'true')
echo "needs-update=${NEEDS_UPDATE}" | tee --append $GITHUB_OUTPUT
- name: Check if commit is associated with a PR
id: pr-check
env:
GH_TOKEN: ${{ github.token }}
run: |
PR_NUMBER=$(gh api \
-H 'Accept: application/vnd.github+json' \
/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls \
--jq '.[0].number')
if [ $? -eq 0 ]; then
PR_INFO=$(gh pr view ${PR_NUMBER} --json author,mergedBy --jq '{author: .author.login, merger: .mergedBy.login}')
AUTHOR=$(echo ${PR_INFO} | jq -r .author)
MERGER=$(echo ${PR_INFO} | jq -r .merger)
else
AUTHOR=${{ github.actor }}
MERGER="none"
fi
echo "author=${AUTHOR}" | tee --append $GITHUB_OUTPUT
echo "merger=${MERGER}" | tee --append $GITHUB_OUTPUT
- name: Open a PR to update the requirements
if: ${{ steps.update.outputs.needs-update }}
uses: peter-evans/create-pull-request@v5
with:
commit-message: update requirements-docker.lock
branch: update-docker-requirements
branch-suffix: timestamp
base: main
title: Update requirements-docker.lock
body: |
Automatic update of requirements-docker.lock.
[Workflow run details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
${{ steps.pr-check.outputs.author != 'none' && format('cc @{0}', steps.pr-check.outputs.author) || '' }}
reviewers: ${{ steps.pr-check.outputs.merger }}
- name: Create failure issue
if: failure()
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
with:
filename: .github/ISSUE_TEMPLATE/DOCKER_ISSUE_TEMPLATE.md