67 lines (67 loc) · 2.49 KB
/
update-s6-overlay.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Update S6 Overlay
on:
push:
branches: main
paths: .github/workflows/update-s6-overlay.yml
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
env:
REGEX: ^(ARG S6_OVERLAY_VERSION=)[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(\-[0-9])?$
steps:
- name: Checkout
uses: actions/checkout@v3.0.2
- name: Determine info
shell: bash
id: info
run: |
OLD_VERSION=$(
grep -oEi "$REGEX" Dockerfile |
grep -oEi '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(\-[0-9])?$'
)
API=https://api.github.com/repos/just-containers/s6-overlay/releases
RELEASES=https://github.com/just-containers/s6-overlay/releases
NEW_VERSION=$(curl -sSf "$API/latest" | jq -r .tag_name)
NEW_VERSION=${NEW_VERSION#'v'}
BUMP='Bump s6 overlay from'
UPDATE_TITLE="$BUMP $OLD_VERSION to $NEW_VERSION"
UPDATE_BODY="$BUMP"
UPDATE_BODY="$UPDATE_BODY [$OLD_VERSION]($RELEASES/v$OLD_VERSION)"
UPDATE_BODY="$UPDATE_BODY to [$NEW_VERSION]($RELEASES/v$NEW_VERSION)."
echo "::set-output name=version::$NEW_VERSION"
echo "::set-output name=update-title::$UPDATE_TITLE"
echo "::set-output name=update-body:: $UPDATE_BODY"
- name: Update Dockerfile
run: sed -i -E "s/$REGEX/\1$VERSION\2/" Dockerfile
env:
VERSION: ${{steps.info.outputs.version}}
- name: Handle changes
uses: peter-evans/create-pull-request@v4.1.1
id: changes
with:
token: ${{secrets.AUTOMATION_TOKEN}}
commit-message: ${{steps.info.outputs.update-title}}
committer: ${{env.GIT_USER}}
add-paths: Dockerfile
author: ${{env.GIT_USER}}
branch: auto/update-s6-overlay
delete-branch: true
title: ${{steps.info.outputs.update-title}}
body: ${{steps.info.outputs.update-body}}
labels: auto,dependencies
env:
GIT_USER: ${{secrets.AUTOMATION_USER}} <${{secrets.AUTOMATION_EMAIL}}>
- name: Enable auto-merge
if: steps.changes.outputs.pull-request-operation == 'created'
run: gh pr merge --auto --squash "$PULL_REQUEST_URL"
env:
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}
GITHUB_TOKEN: ${{secrets.AUTOMATION_TOKEN}}