forked from muchobien/pocketbase-docker
-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (98 loc) · 3.48 KB
/
Copy pathbuild.yml
File metadata and controls
102 lines (98 loc) · 3.48 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# CI / CD of pr0ton11 builds
name: 'Build on upstream release'
on:
push:
branches:
- main
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
jobs:
check:
name: "Check for updates in upstream"
runs-on: ubuntu-latest
outputs:
upstream: ${{ steps.upstream.outputs.result }}
package: ${{ steps.package.outputs.result }}
steps:
- name: Get latest upstream release
id: upstream
uses: actions/github-script@v6
env:
OWNER: pocketbase
REPO: pocketbase
EXCLUDES: '["draft", "prerelease"]'
with:
result-encoding: string
script: |
const {OWNER,REPO,EXCLUDES} = process.env;
const {data} = await github.rest.repos.listReleases({
owner: OWNER,
repo: REPO
})
const releases = data.filter(release => JSON.parse(EXCLUDES).every(exclude => !release[exclude]))
const latest = releases[0]
return latest.tag_name.replace('v','')
- name: Get latest built version in this repo
id: package
uses: actions/github-script@v6
env:
PACKAGE_NAME: pocketbase
PACKAGE_TYPE: container
with:
result-encoding: string
script: |
const {PACKAGE_NAME,PACKAGE_TYPE} = process.env;
const {data: packages} = await github.rest.packages.getAllPackageVersionsForPackageOwnedByUser({
package_type: PACKAGE_TYPE,
package_name: PACKAGE_NAME,
username: context.repo.owner
})
const latest = packages.filter((p) => p.metadata.container.tags.includes("latest"))[0];
return latest.metadata.container.tags.find((v) => /^v?\d+\.\d+\.\d+$/.test(v)) || '0.0.0'
build:
name: "Build"
runs-on: ubuntu-latest
needs: check
if: (needs.check.outputs.upstream != needs.check.outputs.package) || github.event_name != 'workflow_dispatch'
steps:
- name: "Build:checkout"
uses: actions/checkout@v3
- name: "Build:dockerlogin"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build:version"
id: version
run: echo "value=${{ github.event.inputs.version || needs.check.outputs.upstream }}" >> $GITHUB_OUTPUT
- name: "Build:dockerversion"
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/pr0ton11/pocketbase
tags: |
type=semver,pattern={{version}},value=${{ steps.version.outputs.value }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.value }}
type=semver,pattern={{major}},value=${{ steps.version.outputs.value }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: "Build:dockerimage"
uses: docker/build-push-action@v3
with:
context: .
push: true
build-args: VERSION=${{ steps.version.outputs.value }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max