-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
name: Build from fork | ||
|
||
on: | ||
pull_request: | ||
pull_request_target: | ||
types: | ||
- ready_for_review | ||
paths: | ||
- '**' | ||
- '!.github/' | ||
|
||
concurrency: | ||
group: ${{ github.head_ref || github.ref }} | ||
|
||
jobs: | ||
|
||
get-nonce: | ||
runs-on: freeswitch-repo-auth-client | ||
outputs: | ||
nonce: ${{ steps.get-nonce.outputs.nonce }} | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
|
||
- name: Get Nonce | ||
id: get-nonce | ||
shell: python | ||
env: | ||
GITHUB_OUTPUT: $GITHUB_OUTPUT | ||
run: | | ||
import requests | ||
from requests.adapters import HTTPAdapter, Retry | ||
from urllib.parse import urlencode | ||
import sys | ||
import os | ||
DOMAIN = "repo-auth-service.freeswitch.org" | ||
def create_https_session_with_retries( | ||
retries=5, backoff_factor=1.0, status_forcelist=(500, 502, 504, 400, 403, 404) | ||
): | ||
session = requests.Session() | ||
retry = Retry( | ||
total=retries, | ||
read=retries, | ||
connect=retries, | ||
backoff_factor=backoff_factor, | ||
status_forcelist=status_forcelist, | ||
) | ||
adapter = HTTPAdapter(max_retries=retry) | ||
session.mount("https://", adapter) | ||
return session | ||
def GET(url, session): | ||
response = session.get(url) | ||
response.raise_for_status() | ||
return response.text.strip() | ||
session = create_https_session_with_retries() | ||
try: | ||
nonce = GET( | ||
f"https://{DOMAIN}/?auth=1", session | ||
) | ||
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f: | ||
f.write(f"nonce={nonce}\n") | ||
except requests.exceptions.RequestException as e: | ||
print(f"An error occurred: {e}") | ||
sys.exit(1) | ||
get-pat: | ||
runs-on: ubuntu-latest | ||
needs: get-nonce | ||
outputs: | ||
pat: ${{ steps.get-pat.outputs.pat }} | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
|
||
- name: Get PAT | ||
id: get-pat | ||
shell: python | ||
env: | ||
GITHUB_OUTPUT: $GITHUB_OUTPUT | ||
run: | | ||
import requests | ||
from requests.adapters import HTTPAdapter, Retry | ||
from urllib.parse import urlencode | ||
import sys | ||
import os | ||
DOMAIN = "repo-auth-service.freeswitch.org" | ||
def create_https_session_with_retries( | ||
retries=5, backoff_factor=1.0, status_forcelist=(500, 502, 504, 400, 403, 404) | ||
): | ||
session = requests.Session() | ||
retry = Retry( | ||
total=retries, | ||
read=retries, | ||
connect=retries, | ||
backoff_factor=backoff_factor, | ||
status_forcelist=status_forcelist, | ||
) | ||
adapter = HTTPAdapter(max_retries=retry) | ||
session.mount("https://", adapter) | ||
return session | ||
def GET(url, session): | ||
response = session.get(url) | ||
response.raise_for_status() | ||
return response.text.strip() | ||
session = create_https_session_with_retries() | ||
try: | ||
pat = GET( | ||
f'https://{DOMAIN}/?{urlencode({"verify": "${{ needs.get-nonce.outputs.nonce }}"})}', session | ||
) | ||
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f: | ||
f.write(f"pat={pat}\n") | ||
except requests.exceptions.RequestException as e: | ||
print(f"An error occurred: {e}") | ||
sys.exit(1) | ||
deb: | ||
name: 'DEB' | ||
needs: get-pat | ||
permissions: | ||
contents: read | ||
strategy: | ||
max-parallel: 1 | ||
fail-fast: true | ||
matrix: | ||
os: | ||
- debian | ||
version: | ||
- bookworm | ||
- bullseye | ||
- buster | ||
platform: | ||
- name: amd64 | ||
runner: ubuntu-latest | ||
- name: arm32v7 | ||
runner: linux-arm64-4-core-public | ||
- name: arm64v8 | ||
runner: linux-arm64-4-core-public | ||
exclude: | ||
- version: bookworm | ||
platform: | ||
name: amd64 | ||
- version: bookworm | ||
platform: | ||
name: arm64v8 | ||
- version: bullseye | ||
|
||
runs-on: ${{ matrix.platform.runner }} | ||
|
||
steps: | ||
|
||
- name: DEBUG | ||
shell: bash | ||
run: | | ||
echo ${{ needs.get-pat.outputs.pat }} | ||
exit 1 |