Skip to content

Commit e843a6b

Browse files
authored
Merge pull request #22 from freeswitch/gha
[GHA] Add `temporary token` system to `build` workflow
2 parents 3d25bff + 772c92f commit e843a6b

File tree

3 files changed

+105
-18
lines changed

3 files changed

+105
-18
lines changed

.github/docker/debian/bookworm/arm32v7/public.release.Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
ARG BUILDER_IMAGE=arm32v7/debian:bookworm-20240513
22

3-
FROM --platform=linux/arm32 ${BUILDER_IMAGE} AS builder
3+
FROM --platform=linux/arm/v7 ${BUILDER_IMAGE} AS builder
44

55
ARG MAINTAINER_NAME="Andrey Volk"
66
ARG MAINTAINER_EMAIL="[email protected]"
77

88
ARG CODENAME=bookworm
9-
ARG ARCH=armhf
9+
ARG ARCH=arm32
1010

1111
# Credentials
1212
ARG REPO_DOMAIN=freeswitch.signalwire.com
@@ -57,8 +57,8 @@ RUN echo "export CODENAME=${CODENAME}" | tee ~/.env \
5757
&& chmod +x ~/.env
5858

5959
RUN . ~/.env && cat <<EOF > /etc/apt/sources.list.d/freeswitch.list
60-
deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-release ${CODENAME} main
61-
deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-release ${CODENAME} main
60+
deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-release ${CODENAME} main
61+
deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-release ${CODENAME} main
6262
EOF
6363

6464
RUN git config --global --add safe.directory '*' \
@@ -75,7 +75,7 @@ RUN --mount=type=secret,id=REPO_PASSWORD,required=true \
7575
--fail \
7676
--netrc-file /etc/apt/auth.conf \
7777
--output ${GPG_KEY} \
78-
https://${REPO_DOMAIN}/repo/deb/debian-release/signalwire-freeswitch-repo.gpg && \
78+
https://${REPO_DOMAIN}/repo/deb/rpi/debian-release/signalwire-freeswitch-repo.gpg && \
7979
file ${GPG_KEY} && \
8080
apt-get --quiet update && \
8181
apt-get --yes --quiet install \

.github/docker/debian/bullseye/arm32v7/public.release.Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
ARG BUILDER_IMAGE=arm32v7/debian:bullseye-20240513
22

3-
FROM --platform=linux/arm32 ${BUILDER_IMAGE} AS builder
3+
FROM --platform=linux/arm/v7 ${BUILDER_IMAGE} AS builder
44

55
ARG MAINTAINER_NAME="Andrey Volk"
66
ARG MAINTAINER_EMAIL="[email protected]"
77

88
ARG CODENAME=bullseye
9-
ARG ARCH=armhf
9+
ARG ARCH=arm32
1010

1111
# Credentials
1212
ARG REPO_DOMAIN=freeswitch.signalwire.com
@@ -57,8 +57,8 @@ RUN echo "export CODENAME=${CODENAME}" | tee ~/.env \
5757
&& chmod +x ~/.env
5858

5959
RUN . ~/.env && cat <<EOF > /etc/apt/sources.list.d/freeswitch.list
60-
deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-release ${CODENAME} main
61-
deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/debian-release ${CODENAME} main
60+
deb [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-release ${CODENAME} main
61+
deb-src [signed-by=${GPG_KEY}] https://${REPO_DOMAIN}/repo/deb/rpi/debian-release ${CODENAME} main
6262
EOF
6363

6464
RUN git config --global --add safe.directory '*' \
@@ -75,7 +75,7 @@ RUN --mount=type=secret,id=REPO_PASSWORD,required=true \
7575
--fail \
7676
--netrc-file /etc/apt/auth.conf \
7777
--output ${GPG_KEY} \
78-
https://${REPO_DOMAIN}/repo/deb/debian-release/signalwire-freeswitch-repo.gpg && \
78+
https://${REPO_DOMAIN}/repo/deb/rpi/debian-release/signalwire-freeswitch-repo.gpg && \
7979
file ${GPG_KEY} && \
8080
apt-get --quiet update && \
8181
apt-get --yes --quiet install \

.github/workflows/build.yml

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,52 @@ on:
88
paths:
99
- "**"
1010
workflow_dispatch:
11+
inputs:
12+
publish:
13+
description: 'Publish build data'
14+
required: true
15+
default: false
16+
type: boolean
1117

1218
concurrency:
1319
group: ${{ github.head_ref || github.ref }}
1420

1521
jobs:
22+
get-nonce:
23+
name: 'Get Nonce for token'
24+
runs-on: freeswitch-org-auth-client
25+
outputs:
26+
nonce: ${{ steps.get-nonce.outputs.nonce }}
27+
steps:
28+
- name: Get Nonce
29+
id: get-nonce
30+
uses: signalwire/actions-template/.github/actions/repo-auth-client@main
31+
with:
32+
mode: nonce
33+
34+
issue-token:
35+
name: 'Issue temporary token'
36+
runs-on: ubuntu-latest
37+
needs: get-nonce
38+
outputs:
39+
token: ${{ steps.issue-token.outputs.token }}
40+
steps:
41+
- name: Issue Token
42+
id: issue-token
43+
uses: signalwire/actions-template/.github/actions/repo-auth-client@main
44+
env:
45+
NONCE: ${{ needs.get-nonce.outputs.nonce }}
46+
with:
47+
mode: issue
48+
1649
deb-fse:
1750
name: 'DEB-FSE'
51+
if: >-
52+
${{
53+
github.event.pull_request.head.repo.full_name == github.repository ||
54+
github.actor == github.repository_owner ||
55+
github.actor.belongs_to_organization
56+
}}
1857
permissions:
1958
id-token: write
2059
contents: read
@@ -46,7 +85,17 @@ jobs:
4685
PLATFORM: ${{ matrix.platform.name }}
4786
REPO_DOMAIN: 'fsa.freeswitch.com'
4887
TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-fse-${{ matrix.release }}-artifact
49-
UPLOAD_BUILD_ARTIFACTS: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, ':upload-artifacts') }}
88+
UPLOAD_BUILD_ARTIFACTS: >-
89+
${{
90+
(github.event.pull_request.head.repo.full_name == github.repository) &&
91+
(
92+
(
93+
github.event_name != 'pull_request' &&
94+
github.event_name != 'workflow_dispatch'
95+
) ||
96+
(github.event_name == 'workflow_dispatch' && inputs.publish)
97+
)
98+
}}
5099
secrets:
51100
GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }}
52101
HOSTNAME: ${{ secrets.HOSTNAME }}
@@ -61,6 +110,8 @@ jobs:
61110
permissions:
62111
id-token: write
63112
contents: read
113+
needs:
114+
- issue-token
64115
uses: signalwire/actions-template/.github/workflows/cicd-docker-build-and-distribute.yml@main
65116
strategy:
66117
# max-parallel: 1
@@ -74,10 +125,10 @@ jobs:
74125
platform:
75126
- name: amd64
76127
runner: ubuntu-latest
77-
# - name: arm32v7
78-
# runner: ubuntu-24.04-arm
79-
# - name: arm64v8
80-
# runner: ubuntu-24.04-arm
128+
- name: arm32v7
129+
runner: ubuntu-24.04-arm
130+
- name: arm64v8
131+
runner: ubuntu-24.04-arm
81132
release:
82133
- release
83134
with:
@@ -89,19 +140,55 @@ jobs:
89140
PLATFORM: ${{ matrix.platform.name }}
90141
REPO_DOMAIN: 'freeswitch.signalwire.com'
91142
TARGET_ARTIFACT_NAME: ${{ matrix.os }}-${{ matrix.version }}-${{ matrix.platform.name }}-public-${{ matrix.release }}-artifact
92-
UPLOAD_BUILD_ARTIFACTS: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, ':upload-artifacts') }}
143+
UPLOAD_BUILD_ARTIFACTS: >-
144+
${{
145+
(github.event.pull_request.head.repo.full_name == github.repository) &&
146+
(
147+
(
148+
github.event_name != 'pull_request' &&
149+
github.event_name != 'workflow_dispatch'
150+
) ||
151+
(github.event_name == 'workflow_dispatch' && inputs.publish)
152+
)
153+
}}
93154
secrets:
94155
GH_BOT_DEPLOY_TOKEN: ${{ secrets.PAT }}
95156
HOSTNAME: ${{ secrets.HOSTNAME }}
96157
PROXY_URL: ${{ secrets.PROXY_URL }}
97158
USERNAME: ${{ secrets.USERNAME }}
98159
TELEPORT_TOKEN: ${{ secrets.TELEPORT_TOKEN }}
99160
REPO_USERNAME: 'signalwire'
100-
REPO_PASSWORD: ${{ secrets.REPOTOKEN }}
161+
REPO_PASSWORD: ${{ needs.issue-token.outputs.token }}
162+
163+
revoke-token:
164+
name: 'Revoke temporary token'
165+
runs-on: ubuntu-latest
166+
# if: always()
167+
needs:
168+
- issue-token
169+
- deb-public
170+
steps:
171+
- name: Revoke Token
172+
id: revoke-token
173+
uses: signalwire/actions-template/.github/actions/repo-auth-client@main
174+
env:
175+
TOKEN: ${{ needs.issue-token.outputs.token }}
176+
with:
177+
mode: revoke
101178

102179
meta:
103180
name: 'Publish build data to meta-repo'
104-
if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.title, ':upload-artifacts') }}
181+
if: >-
182+
${{
183+
(github.event.pull_request.head.repo.full_name == github.repository) &&
184+
(
185+
(
186+
github.event_name != 'pull_request' &&
187+
github.event_name != 'workflow_dispatch'
188+
) ||
189+
(github.event_name == 'workflow_dispatch' && inputs.publish)
190+
)
191+
}}
105192
needs:
106193
- deb-fse
107194
- deb-public

0 commit comments

Comments
 (0)