Skip to content

Commit

Permalink
Hopefully fix SS13 repo sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss committed Aug 11, 2024
1 parent c0c286a commit 3d5d231
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/update-ss13-org-mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,36 @@ jobs:
dotnet-version: '${{ env.TGS_DOTNET_VERSION }}.0.x'
dotnet-quality: ${{ env.TGS_DOTNET_QUALITY }}

- name: Checkout
- name: Build Checkout
uses: actions/checkout@v4
with:
path: temp_workspace

- name: Restore
run: |
cd temp_workspace
dotnet restore
- name: Build ReleaseNotes
run: |
cd temp_workspace
dotnet build -c Release -p:TGS_HOST_NO_WEBPANEL=true tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj
- name: Generate App Token
run: |
cd temp_workspace
dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --token-output-file ${{ runner.temp }}/installation_secret.txt ${{ secrets.TGS_CI_GITHUB_APP_TOKEN_BASE64 }} --spacestation13
echo "INSTALLATION_TOKEN=$(cat ${{ runner.temp }}/installation_secret.txt)" >> $GITHUB_ENV
rm ${{ runner.temp }}/installation_secret.txt
env:
TGS_RELEASE_NOTES_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }}

- name: Main Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
token: ${{ env.INSTALLATION_TOKEN }}

- name: Restore
run: dotnet restore
Expand Down
15 changes: 10 additions & 5 deletions tools/Tgstation.Server.ReleaseNotes/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static async Task<int> Main(string[] args)
return 454233;
}

await GenerateAppCredentials(client, args[1]);
await GenerateAppCredentials(client, args[1], false);

return await EnsureRelease(client);
}
Expand Down Expand Up @@ -171,7 +171,8 @@ static async Task<int> Main(string[] args)
return 33847;
}

await GenerateAppCredentials(client, args[2]);
bool toSS13 = args.Length > 3 && args[3].Equals("--spacestation13", StringComparison.OrdinalIgnoreCase);
await GenerateAppCredentials(client, args[2], true);

var token = client.Credentials.GetToken();
var destPath = args[1];
Expand Down Expand Up @@ -1640,7 +1641,7 @@ [optional blank line(s), stripped]
return 0;
}

static async ValueTask GenerateAppCredentials(GitHubClient gitHubClient, string pemBase64)
static async ValueTask GenerateAppCredentials(GitHubClient gitHubClient, string pemBase64, bool toSS13)
{
var pemBytes = Convert.FromBase64String(pemBase64);
var pem = Encoding.UTF8.GetString(pemBytes);
Expand All @@ -1665,15 +1666,19 @@ static async ValueTask GenerateAppCredentials(GitHubClient gitHubClient, string

gitHubClient.Credentials = new Credentials(jwtStr, AuthenticationType.Bearer);

var installation = await gitHubClient.GitHubApps.GetRepositoryInstallationForCurrent(RepoOwner, RepoName);
var installation = await gitHubClient.GitHubApps.GetRepositoryInstallationForCurrent(
toSS13
? "spacestation13"
: RepoOwner,
RepoName);
var installToken = await gitHubClient.GitHubApps.CreateInstallationToken(installation.Id);

gitHubClient.Credentials = new Credentials(installToken.Token);
}

static async ValueTask<int> CICompletionCheck(GitHubClient gitHubClient, string currentSha, string pemBase64)
{
await GenerateAppCredentials(gitHubClient, pemBase64);
await GenerateAppCredentials(gitHubClient, pemBase64, false);

await gitHubClient.Check.Run.Create(RepoOwner, RepoName, new NewCheckRun("CI Completion", currentSha)
{
Expand Down

0 comments on commit 3d5d231

Please sign in to comment.