-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (78 loc) · 3.42 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
71
72
73
74
75
76
77
78
name: Update Container (latest)
on:
schedule:
- cron: '10 0 * * *' # Every Day
workflow_dispatch:
inputs:
force_deploy:
description: 'Force a container build, even if no changes'
required: true
default: 'false'
push:
branches:
- 'main'
paths:
- 'Dockerfile.*'
- '.github/workflows/**'
jobs:
check-upstream:
name: Check for new upstream revision
runs-on: ubuntu-latest
outputs:
modified: ${{ steps.git-check.outputs.modified }}
upstream-tag: ${{ steps.upstream-tag.outputs.upstream-tag }}
upstream-major: ${{ steps.upstream-tag.outputs.upstream-major }}
upstream-minor: ${{ steps.upstream-tag.outputs.upstream-minor }}
steps:
- uses: actions/checkout@v2
- name: Fetch release version
run: |
git fetch
# Get releases
curl -sL 'https://api.github.com/repos/apache/superset/releases' > /tmp/releases_temp.json
# Extract latest tag of 1.x.x (exclude release candidates)
tagName=$(jq -r '[ .[] | select( .tag_name | test("^1\\.[0-9]+\\.[0-9]+$") ) ] | max_by( .tag_name | split(".") | map(tonumber) ) | .tag_name' /tmp/releases_temp.json)
# Store superset-latest.json
jq --arg tagName "$tagName" -r ".[] | select( .tag_name == \"$tagName\" ) | del(.reactions)" /tmp/releases_temp.json > superset-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
id: upstream-tag
run: |
upstreamTag=$(jq -r '.tag_name' superset-latest.json)
echo ::set-output name=upstream-tag::${upstreamTag}
echo ::set-output name=upstream-major::${upstreamTag%%.*}
echo ::set-output name=upstream-minor::${upstreamTag%.*}
- 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' ||
( github.event_name == 'push' ) ||
( github.event_name == 'workflow_dispatch' && github.event.inputs.force_deploy != 'false' )
strategy:
matrix:
DOCKER_IMAGE: [superset-oauth] # Array: [superset,superset-oauth]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use upstream tag (${{ needs.check-upstream.outputs.upstream-tag }}) in Dockerfile
run: |
sed -i'' "s/FROM apache\/superset AS/FROM apache\/superset:${{ needs.check-upstream.outputs.upstream-tag }} AS/" Dockerfile.${{ matrix.DOCKER_IMAGE }}
- name: Publish to GitHub Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: ghcr.io/${{ github.repository_owner }}/${{ matrix.DOCKER_IMAGE }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
dockerfile: Dockerfile.${{ matrix.DOCKER_IMAGE }}
tags: "latest,stable,v${{ needs.check-upstream.outputs.upstream-tag }},v${{ needs.check-upstream.outputs.upstream-major }},v${{ needs.check-upstream.outputs.upstream-minor }}"