This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
forked from AaronDewes/lnbits
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (76 loc) · 2.72 KB
/
on-push.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
name: Build on push
permissions:
packages: write
on:
push:
branches:
- main
- feat/admin-password
jobs:
build-amd64:
name: Build image (AMD64)
runs-on: ubuntu-20.04
steps:
- name: Checkout project
uses: actions/checkout@v2
- name: Set env variables
run: |
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_ENV
IMAGE_NAME="${GITHUB_REPOSITORY#*/}"
echo "IMAGE_NAME=${IMAGE_NAME//docker-/}" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker buildx action
uses: docker/setup-buildx-action@v1
- name: Run Docker buildx
run: |
docker buildx build \
--platform linux/amd64 \
--tag ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$BRANCH-amd64 \
--output "type=registry" ./
build-arm64:
name: Build image (ARM64)
runs-on: self-hosted
steps:
- name: Checkout project
uses: actions/checkout@v2
- name: Set env variables
run: |
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_ENV
IMAGE_NAME="${GITHUB_REPOSITORY#*/}"
echo "IMAGE_NAME=${IMAGE_NAME//docker-/}" >> $GITHUB_ENV
- name: Login to Docker Hub
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Run Docker buildx
run: |
docker buildx build \
--platform linux/arm64 \
--network host \
--tag ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$BRANCH-arm64 \
--output "type=registry" ./
create-manifest:
name: Create two-architecture manifest
runs-on: ubuntu-20.04
needs:
- build-amd64
- build-arm64
steps:
- name: Checkout project
uses: actions/checkout@v2
- name: Set env variables
run: |
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_ENV
IMAGE_NAME="${GITHUB_REPOSITORY#*/}"
echo "IMAGE_NAME=${IMAGE_NAME//docker-/}" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create final manifest
run: ./create-manifest.sh "ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}" "${BRANCH}"