-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (70 loc) · 3.74 KB
/
upstream-latest.yaml
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
68
69
70
name: Update Container (latest)
on:
schedule:
- cron: '10 0 * * *' # Every Day
workflow_dispatch:
jobs:
check-upstream:
name: Check for new upstream revision
runs-on: ubuntu-latest
outputs:
modified: ${{ steps.git-check.outputs.modified }}
s6-tag: ${{ steps.rclone-tag.outputs.s6-tag }}
rclone-tag: ${{ steps.rclone-tag.outputs.rclone-tag }}
rclone-major: ${{ steps.rclone-tag.outputs.rclone-major }}
rclone-minor: ${{ steps.rclone-tag.outputs.rclone-minor }}
steps:
- uses: actions/checkout@v2
- name: Fetch release version
run: |
# Get S6 releases
curl -sL 'https://api.github.com/repos/just-containers/s6-overlay/releases' > /tmp/releases_temp.json
# Extract latest tag of 2.x.x (exclude release candidates)
tagName="v$(jq -r '[ .[] | .tag_name |= sub("^v";"") | select( .tag_name | test("^2\\.[0-9]+\\.[0-9]+\\.[0-9]+$") ) ] | max_by( .tag_name | split(".") | map(tonumber) ) | .tag_name' /tmp/releases_temp.json)"
# Store s6-latest.json
jq --arg tagName "$tagName" -r ".[] | select( .tag_name == \"$tagName\" ) | del(.assets, .reactions)" /tmp/releases_temp.json > s6-latest.json
# Get rclone releases
curl -sL 'https://api.github.com/repos/rclone/rclone/releases' > /tmp/releases_temp.json
# Extract latest tag of 1.x.x (exclude release candidates)
tagName="v$(jq -r '[ .[] | .tag_name |= sub("^v";"") | select( .tag_name | test("^1\\.[0-9]+\\.[0-9]+$") ) ] | max_by( .tag_name | split(".") | map(tonumber) ) | .tag_name' /tmp/releases_temp.json)"
# Store rclone-latest.json
jq --arg tagName "$tagName" -r ".[] | select( .tag_name == \"$tagName\" ) | del(.assets, .reactions)" /tmp/releases_temp.json > rclone-latest.json
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "unchanged" || echo "true")
- name: Store upstream tag
if: steps.git-check.outputs.modified == 'true'
id: rclone-tag
run: |
echo ::set-output name=s6-tag::$(jq -r '.tag_name' s6-latest.json)
rcloneTag=$(jq -r '.tag_name' rclone-latest.json)
echo ::set-output name=rclone-tag::${rcloneTag}
echo ::set-output name=rclone-major::${rcloneTag%%.*}
echo ::set-output name=rclone-minor::${rcloneTag%.*}
- name: Commit latest upstream revision
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name '${{ github.actor }}'
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
git commit -am "New upstream revision"
git push
publish-image:
name: Publish to ghcr.io
needs: check-upstream
if: needs.check-upstream.outputs.modified == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use upstream tag (${{ needs.check-upstream.outputs.rclone-tag }}) in Dockerfile
run: |
sed -i'' "s/RCLONE_VERSION=\"v1.54.1\"/RCLONE_VERSION=\"${{ needs.check-upstream.outputs.rclone-tag }}\"/" Dockerfile
sed -i'' "s/OVERLAY_VERSION=\"v1.22.1.0\"/OVERLAY_VERSION=\"${{ needs.check-upstream.outputs.s6-tag }}\"/" Dockerfile
- name: Publish to GitHub Registry
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: ghcr.io/${{ github.repository_owner }}/rclone-mount
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
dockerfile: Dockerfile
tags: "latest,stable,${{ needs.check-upstream.outputs.rclone-tag }},${{ needs.check-upstream.outputs.rclone-major }},${{ needs.check-upstream.outputs.rclone-minor }}"