-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (128 loc) · 5.68 KB
/
build.yml
File metadata and controls
142 lines (128 loc) · 5.68 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build Images
on:
workflow_dispatch:
jobs:
docker:
environment: Docker build
strategy:
fail-fast: false
matrix:
branch:
- STABLE
runs-on: [ubuntu-latest]
steps:
-
name: Checkout
uses: actions/checkout@v3.3.0
- name: Get run meta
id: get-run-meta
run: |
echo "vars - Branch: ${{ vars.UPSTREAM_REPO }} Branch: ${{vars[matrix.branch]}} WF: ${{ vars.UPSTREAM_WF }}"
RESPONSE=`gh run --repo ${{ vars.UPSTREAM_REPO }} list --branch ${{vars[matrix.branch]}} --workflow "${{ vars.UPSTREAM_WF }}" --json headBranch,headSha,databaseId,conclusion --jq '[.[0].databaseId, .[0].headSha, .[0].headBranch, .[0].conclusion] | @tsv' --limit 1`
echo "RESPONSE: $RESPONSE"
echo run_id=$(echo $RESPONSE | cut -f1 -d' ') >> $GITHUB_OUTPUT
echo head_sha=$(echo $RESPONSE | cut -f2 -d' ') >> $GITHUB_OUTPUT
echo branch=$(echo $RESPONSE | cut -f3 -d' ') >> $GITHUB_OUTPUT
echo success=$(echo $RESPONSE | cut -f4 -d' ') >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
if: steps.get-run-meta.outputs.success == 'success'
name: Set Gist File Name
run: |
echo "GIST_NAME=${{vars[matrix.branch]}}.txt" >> "$GITHUB_ENV"
-
if: steps.get-run-meta.outputs.success == 'success'
name: Read Gist
uses: sergeysova/gist-read-action@v1.0.0
id: gist-read
with:
gist_id: ${{ vars[env.GIST_KEY] }}
file_name: ${{ env.GIST_NAME }}
env:
GIST_KEY: GIST_${{matrix.branch}}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
-
if: steps.get-run-meta.outputs.success == 'success'
name: Check if build is needed
id: check-build
run: |
echo build_needed=${{ steps.gist-read.outputs.content != steps.get-run-meta.outputs.head_sha }} >> $GITHUB_OUTPUT
-
if: steps.get-run-meta.outputs.success == 'success' && steps.check-build.outputs.build_needed == 'true'
run: |
mkdir -p ./extras
- name: Download application.yml
if: steps.check-build.outputs.build_needed == 'true'
run: |
curl -o ./extras/application-ignore.yml ${{ vars.APPLICATION_YAML }}
-
name: "Download Latest Lavalink.jar"
if: steps.get-run-meta.outputs.success == 'success' && steps.check-build.outputs.build_needed == 'true'
run: |
gh run --repo "${{ vars.UPSTREAM_REPO }}" download ${{steps.get-run-meta.outputs.run_id}} -n "${{ vars.UPSTREAM_ARTIFACT }}" --dir ./extras
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
if: steps.get-run-meta.outputs.success == 'success' && steps.check-build.outputs.build_needed == 'true'
id: meta
uses: docker/metadata-action@v4.3.0
with:
# list of Docker images to use as base name for tags
images: |
drapersniper/node
ghcr.io/pylav/node
# generate Docker tags based on the following events/attributes
tags: |
type=raw,enable=true,priority=1000,prefix=${{steps.get-run-meta.outputs.branch}}-,value=latest
type=raw,enable=true,priority=900,prefix=,suffix=,value=${{steps.get-run-meta.outputs.branch}}
type=raw,enable=true,priority=100,prefix=sha-,suffix=,value=${{steps.get-run-meta.outputs.head_sha}}
type=raw,value=latest,enable=${{ steps.get-run-meta.outputs.branch == vars.STABLE }}
-
name: Set up QEMU
if: steps.get-run-meta.outputs.success == 'success' && steps.check-build.outputs.build_needed == 'true'
uses: docker/setup-qemu-action@v2.1.0
-
name: Set up Docker Buildx
if: steps.get-run-meta.outputs.success == 'success' && steps.check-build.outputs.build_needed == 'true'
uses: docker/setup-buildx-action@v2.4.1
-
name: Login to Docker Hub
if: github.event_name != 'pull_request' && steps.get-run-meta.outputs.success == 'success' && steps.check-build.outputs.build_needed == 'true'
uses: docker/login-action@v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GHCR
if: github.event_name != 'pull_request' && steps.get-run-meta.outputs.success == 'success' && steps.check-build.outputs.build_needed == 'true'
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
if: steps.get-run-meta.outputs.success == 'success' && steps.check-build.outputs.build_needed == 'true'
uses: docker/build-push-action@v4.0.0
with:
context: .
platforms: |
linux/amd64
linux/arm/v7
linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ env.GIST_NAME }}
cache-to: type=gha,mode=max,scope=${{ env.GIST_NAME }}
- name: Update Gist
if: steps.check-build.outputs.build_needed == 'true'
uses: sergeysova/gist-write-action@v1.0.0
with:
gist_id: ${{ vars[env.GIST_KEY] }}
file_name: ${{ env.GIST_NAME }}
content: ${{steps.get-run-meta.outputs.head_sha}}
env:
GIST_KEY: GIST_${{matrix.branch}}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}