-
Notifications
You must be signed in to change notification settings - Fork 34
feat(ibmcloud): add GitHub Actions runner support for IBM Power and IBM Z #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deekay2310
wants to merge
17
commits into
redhat-developer:main
Choose a base branch
from
deekay2310:ibmcloud-gh-runners
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c9a4b05
feat(ibmcloud): add GitHub Actions runner support for IBM Power and I…
deekay2310 9af3e13
fix: harden --ghactions-runner-image-repo input
deekay2310 f68b509
feat(ibmcloud): auto-generate GitHub Actions runner registration token
deekay2310 68f31f4
fix(ibmcloud): install prerequisites before runner image build
deekay2310 78d423b
ci: add s390x runner smoke test workflow
deekay2310 753b7ef
fix(ibmcloud): tolerate flaky upstream test failures in runner build
deekay2310 9e03696
fix(ibmcloud): preserve runner binary if post-build installer fails
deekay2310 7829062
revert: remove unnecessary runner binary watcher from snippets
deekay2310 a6893f0
fix(ibmcloud): run GitHub Actions runner as non-root user
deekay2310 60e93b8
fix(ibmcloud): repair PAM config after runner build to preserve sshd
deekay2310 ef87753
debug(ibmcloud): add sshd watchdog and diagnostic logging to ppc64le …
deekay2310 265345e
fix(ibmcloud): restore sshd privsep dir after runner build + COS diag…
deekay2310 de8fc1f
fix(ibmcloud): remove nonexistent /opt/dotnet from ppc64le snippet
deekay2310 9f02ad6
feat(ibmcloud): auto-discover Power VS system type based on pool capa…
deekay2310 246c1c0
fix(ibmcloud): harden GH runner params and system pool selection
deekay2310 28e55f7
fix(ibmcloud): remove nonexistent /opt/dotnet from s390x snippet
deekay2310 107ab7f
feat(ibmcloud): zone-level system type discovery with retry on capacity
deekay2310 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,11 @@ | ||
| name: s390x Runner Smoke Test | ||
| on: workflow_dispatch | ||
| jobs: | ||
| smoke-test: | ||
| runs-on: [self-hosted, S390X] | ||
| steps: | ||
| - name: Check architecture | ||
| run: | | ||
| echo "Architecture: $(uname -m)" | ||
| cat /etc/os-release | grep PRETTY_NAME | ||
| echo "Runner is alive on $(arch)" |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,68 @@ | ||
| package github | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| "io" | ||
| "net/http" | ||
| "strings" | ||
| "time" | ||
| ) | ||
|
|
||
| type registrationTokenResponse struct { | ||
| Token string `json:"token"` | ||
| ExpiresAt string `json:"expires_at"` | ||
| } | ||
|
|
||
| // GenerateRegistrationToken calls the GitHub API to create a short-lived | ||
| // runner registration token for the given repository. | ||
| // pat is a Personal Access Token with repo admin scope. | ||
| // repoURL is in the form "owner/repo" or "https://github.com/owner/repo". | ||
| func GenerateRegistrationToken(pat, repoURL string) (string, error) { | ||
| ownerRepo := repoURL | ||
| ownerRepo = strings.TrimPrefix(ownerRepo, "https://github.com/") | ||
| ownerRepo = strings.TrimPrefix(ownerRepo, "http://github.com/") | ||
| ownerRepo = strings.TrimSuffix(ownerRepo, "/") | ||
|
|
||
| parts := strings.Split(ownerRepo, "/") | ||
| if len(parts) != 2 || parts[0] == "" || parts[1] == "" { | ||
| return "", fmt.Errorf("invalid repo format %q, expected owner/repo", repoURL) | ||
| } | ||
|
|
||
| url := fmt.Sprintf("https://api.github.com/repos/%s/%s/actions/runners/registration-token", parts[0], parts[1]) | ||
|
|
||
| req, err := http.NewRequest(http.MethodPost, url, nil) | ||
| if err != nil { | ||
| return "", fmt.Errorf("creating request: %w", err) | ||
| } | ||
| req.Header.Set("Authorization", "token "+pat) | ||
| req.Header.Set("Accept", "application/vnd.github+json") | ||
| req.Header.Set("X-GitHub-Api-Version", "2022-11-28") | ||
|
|
||
| client := &http.Client{Timeout: 30 * time.Second} | ||
| resp, err := client.Do(req) | ||
| if err != nil { | ||
| return "", fmt.Errorf("calling GitHub API: %w", err) | ||
| } | ||
| defer func() { _ = resp.Body.Close() }() | ||
|
|
||
| body, err := io.ReadAll(resp.Body) | ||
| if err != nil { | ||
| return "", fmt.Errorf("reading response: %w", err) | ||
| } | ||
|
|
||
| if resp.StatusCode != http.StatusCreated { | ||
| return "", fmt.Errorf("GitHub API returned %d: %s (ensure GITHUB_TOKEN has admin scope on the repo)", resp.StatusCode, string(body)) | ||
| } | ||
|
|
||
| var tokenResp registrationTokenResponse | ||
| if err := json.Unmarshal(body, &tokenResp); err != nil { | ||
| return "", fmt.Errorf("parsing response: %w", err) | ||
| } | ||
|
|
||
| if tokenResp.Token == "" { | ||
| return "", fmt.Errorf("empty token in GitHub API response") | ||
| } | ||
|
|
||
| return tokenResp.Token, nil | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.