Skip to content

Update S6 Overlay #1459

Update S6 Overlay

Update S6 Overlay #1459

name: Update S6 Overlay
on:
schedule:
- cron: 0 15 * * *
workflow_dispatch:
permissions:
contents: read
concurrency: update-s6-overlay
jobs:
update-s6-overlay:
name: Update S6 Overlay
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
branch:
- main
- release/jammy
- release/focal
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
with:
ref: ${{matrix.branch}}
- name: Generate app token
id: app-token
uses: actions/create-github-app-token@v3.0.0
with:
app-id: ${{secrets.GH_APP_ID}}
private-key: ${{secrets.GH_APP_PRIVATE_KEY}}
- name: Determine info
shell: bash
id: info
run: |
VERSION_REGEX='([0-9]+\.){3}[0-9]+(\-[0-9]+)?'
REGEX="^((ARG | {4})?S6_OVERLAY_VERSION=)${VERSION_REGEX}$"
OLD_VERSION=$(
grep -oEi "${REGEX}" Dockerfile |
grep -oEi "${VERSION_REGEX}"
)
NEW_VERSION=$(
gh release list \
-R just-containers/s6-overlay \
--json isLatest,tagName \
-q ".[] | select(.isLatest) | .tagName"
)
NEW_VERSION=${NEW_VERSION#'v'}
RELEASES='https://github.com/just-containers/s6-overlay/releases'
UPDATE_TITLE="Bump s6 overlay from ${OLD_VERSION} to ${NEW_VERSION}"
UPDATE_BODY='Bump s6 overlay from'
UPDATE_BODY+="[${OLD_VERSION}](${RELEASES}/v${OLD_VERSION}) "
UPDATE_BODY+="to [${NEW_VERSION}](${RELEASES}/v${NEW_VERSION})."
USER_NAME="${GITHUB_APP_SLUG}[bot]"
USER_ID=$(gh api "/users/${USER_NAME}" --jq '.id')
USER_EMAIL="${USER_ID}+${USER_NAME}@users.noreply.github.com"
COMMIT_AUTHOR="${USER_NAME} <${USER_EMAIL}>"
echo "replace-regex=${REGEX}" >> "${GITHUB_OUTPUT}"
echo "s6-overlay-version=${NEW_VERSION}" >> "${GITHUB_OUTPUT}"
echo "update-title=${UPDATE_TITLE}" >> "${GITHUB_OUTPUT}"
echo "update-body=${UPDATE_BODY}" >> "${GITHUB_OUTPUT}"
echo "commit-author=${COMMIT_AUTHOR}" >> "${GITHUB_OUTPUT}"
env:
GITHUB_TOKEN: ${{steps.app-token.outputs.token}}
GITHUB_APP_SLUG: ${{steps.app-token.outputs.app-slug}}
- name: Update Dockerfile
run: sed -i -E "s/${REPLACE_REGEX}/\1${S6_OVERLAY_VERSION}/" Dockerfile
env:
S6_OVERLAY_VERSION: ${{steps.info.outputs.s6-overlay-version}}
REPLACE_REGEX: ${{steps.info.outputs.replace-regex}}
- name: Handle changes
uses: peter-evans/create-pull-request@v8.1.0
id: changes
with:
token: ${{steps.app-token.outputs.token}}
commit-message: ${{steps.info.outputs.update-title}}
author: ${{steps.info.outputs.commit-author}}
committer: ${{steps.info.outputs.commit-author}}
add-paths: Dockerfile
base: ${{matrix.branch}}
branch: auto/update-s6-overlay/${{matrix.branch}}
delete-branch: true
title: ${{steps.info.outputs.update-title}}
body: ${{steps.info.outputs.update-body}}
labels: |
dependencies
auto
- name: Enable auto merge
if: steps.changes.outputs.pull-request-operation == 'created'
run: gh pr merge --auto --squash "${PULL_REQUEST_URL}"
env:
GITHUB_TOKEN: ${{steps.app-token.outputs.token}}
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}