-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (100 loc) · 4.25 KB
/
build.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
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
name: 'Deploy'
on:
push:
branches:
- dev
tags:
- '*'
pull_request:
env:
IMAGE_NAME: "flipperdevices/github-actions-runner"
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: 'Checkout code'
uses: actions/checkout@v4
- name: 'Install Helm'
uses: azure/[email protected]
- name: 'Set image tag and name'
id: tag
run: |
IMAGE_TAG="0.0.0"
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
REF=${{ github.ref }};
TAG_FULL=${REF#refs/*/};
IMAGE_TAG=${TAG_FULL//\//_};
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
- name: 'Login to Docker Hub'
uses: docker/login-action@v3
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: 'Set up Docker Buildx'
uses: docker/setup-buildx-action@v3
- name: 'Build android'
uses: docker/build-push-action@v6
with:
push: false
tags: ${{ steps.tag.outputs.image_name }}-android:${{ steps.tag.outputs.image_tag }}
cache-from: type=registry,ref=${{ steps.tag.outputs.image_name }}-android:buildcache
context: android
- name: 'Build flipperzero-firmware'
uses: docker/build-push-action@v6
with:
push: false
tags: ${{ steps.tag.outputs.image_name }}-fz-fw:${{ steps.tag.outputs.image_tag }}
cache-from: type=registry,ref=${{ steps.tag.outputs.image_name }}-fz-fw:buildcache
context: flipperzero-firmware
- name: 'Push android'
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.tag.outputs.image_name }}-android:${{ steps.tag.outputs.image_tag }}
cache-from: type=registry,ref=${{ steps.tag.outputs.image_name }}-android:buildcache
cache-to: type=registry,ref=${{ steps.tag.outputs.image_name }}-android:buildcache,mode=max
context: android
- name: 'Push flipperzero-firmware'
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.tag.outputs.image_name }}-fz-fw:${{ steps.tag.outputs.image_tag }}
cache-from: type=registry,ref=${{ steps.tag.outputs.image_name }}-fz-fw:buildcache
cache-to: type=registry,ref=${{ steps.tag.outputs.image_name }}-fz-fw:buildcache,mode=max
context: flipperzero-firmware
- name: 'Login to Docker Hub'
uses: docker/login-action@v3
with:
registry: registry-1.docker.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: 'Push helm chart'
if: ${{ github.event_name != 'pull_request' }}
run: |
helm package helm --version ${IMAGE_TAG};
helm push github-actions-runner-${IMAGE_TAG}.tgz oci://registry-1.docker.io/flipperdevices;
- name: 'Trigger k8s to use new image android: prod'
if: ${{ (github.event_name != 'pull_request')
&& (steps.tag.outputs.image_tag != '0.0.0')
&& (!endsWith(github.event.client_payload.image_tag, '-rc')) }}
uses: peter-evans/repository-dispatch@v3
with:
repository: ${{ secrets.INFRASTRUCTURE_REPO }}
token: ${{ secrets.K8S_GITHUB_PAT }}
event-type: github-actions-runner-fz-fw-deploy-android-deploy
client-payload: '{"image_tag": "${{steps.tag.outputs.image_tag}}"}'
- name: 'Trigger k8s to use new image flipperzero-firmware: prod'
if: ${{ (github.event_name != 'pull_request')
&& (steps.tag.outputs.image_tag != '0.0.0')
&& (!endsWith(github.event.client_payload.image_tag, '-rc')) }}
uses: peter-evans/repository-dispatch@v3
with:
repository: ${{ secrets.INFRASTRUCTURE_REPO }}
token: ${{ secrets.K8S_GITHUB_PAT }}
event-type: github-actions-runner-fz-fw-deploy-fz-fw-deploy
client-payload: '{"image_tag": "${{steps.tag.outputs.image_tag}}"}'