Add New Docker Versions #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Add New Docker Versions | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * 3" | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
generate_and_raise_pr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Pip | |
working-directory: ./workflow_scripts | |
run: pip install -r requirements.txt | |
- name: Check if new versions available | |
id: check-versions | |
run: | | |
python -u workflow_scripts/check-for-new-versions.py | |
env: | |
EXCLUDED_VERSIONS: "v20.10.x,v23.0.x,v25.0.x,v26.1.x" | |
- name: check if the PR exist | |
if: ${{ env.PR_TITLE != '' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_TITLE: ${{env.PR_TITLE}} | |
run: | | |
EXISTING_PR=$(gh pr list --limit 1500 --json title,url | jq --arg title "${PR_TITLE}" -r '.[] | select(.title==$title) | .url') | |
if [ -n "${EXISTING_PR}" ]; then | |
echo "pr_exist=true" >> $GITHUB_ENV | |
echo "Pull request already exists: ${EXISTING_PR}" >> $GITHUB_STEP_SUMMARY | |
else | |
echo "pr_exist=false" >> $GITHUB_ENV | |
fi | |
- name: generate files for new docker version | |
if: ${{ env.pr_exist == 'false' && env.PR_TITLE != '' }} | |
env: | |
NEW_VERSIONS: ${{ env.NEW_VERSIONS }} | |
run: | | |
python -u workflow_scripts/gen-new-version-files.py | |
- name: Create branch, commit and push | |
if: ${{ env.pr_exist == 'false' && env.PR_TITLE != '' }} | |
id: branch | |
env: | |
NEW_VERSIONS: ${{ env.NEW_VERSIONS }} | |
run: | | |
BRANCH="gha-add-tag-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" | |
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT | |
git config user.name github-actions | |
git config user.email [email protected] | |
git checkout -b "$BRANCH" | |
git add . | |
git commit -m "added docker ${NEW_VERSIONS}" | |
git push origin "$BRANCH" | |
- name: Create Pull Request | |
if: ${{ env.pr_exist == 'false' && env.PR_TITLE != '' }} | |
id: cpr | |
env: | |
SOURCE_BRANCH: ${{ steps.branch.outputs.branch }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_TITLE: ${{env.PR_TITLE}} | |
PR_BODY: autogenerated PR to add docker ${{env.NEW_VERSIONS}} | |
run: | | |
PR_TITLE=$(echo "$PR_TITLE" | cut -c -256) | |
CREATED_PR=$(gh pr create --title "${PR_TITLE}" --body "${PR_BODY}" --label "status/auto-created" --base "${GITHUB_REF_NAME}" --head "${SOURCE_BRANCH}") | |
echo "Created pull request: ${CREATED_PR}" >> $GITHUB_STEP_SUMMARY |