Skip to content

Commit

Permalink
TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rj1k committed Jul 5, 2024
1 parent 98f164d commit 995b3d1
Showing 1 changed file with 175 additions and 0 deletions.
175 changes: 175 additions & 0 deletions .github/workflows/build-from-fork.yml
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

0 comments on commit 995b3d1

Please sign in to comment.