From fb4c8ac839e5dd37ed0f8124d9393c1983f22ffe Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 10 Jan 2023 21:42:10 +0000 Subject: [PATCH] CI - Added support for new update backend --- .github/workflows/master.yml | 65 +++++++++++++++--------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index f6c55d811..ad9362d6c 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -76,46 +76,33 @@ jobs: name: artemis-${{ matrix.rid }}-${{ needs.version.outputs.version-number }} path: build/${{ matrix.rid }} - ftp: - name: Ftp Upload + notify: + name: Notify Backend of build runs-on: ubuntu-latest - needs: [version, build] + needs: build steps: - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - name: Zip and Hash artifacts + - name: post thing + if: needs.build.result == 'success' run: | - New-Item -ItemType "Directory" -Path ftp/ - Get-ChildItem -Directory artifacts | - Foreach-Object -Parallel { - Compress-Archive -Path "artifacts/$($_.Name)" -DestinationPath "ftp/$($_.Name).zip" -Verbose - (Get-FileHash -Algorithm MD5 "ftp/$($_.Name).zip").Hash | Out-File -FilePath "ftp/$($_.Name).md5" -Verbose + $tokenUri = "https://identity.artemis-rgb.com/connect/token" + + $headers = @{ + "Content-Type" = "application/x-www-form-urlencoded" } - shell: pwsh - - name: Upload builds to FTP - uses: dennisameling/ftp-upload-action@v1 - with: - server: artemis-rgb.com - username: ${{ secrets.FTP_USER }} - password: ${{ secrets.FTP_PASSWORD }} - secure: false - local_dir: ftp/ - server_dir: /builds.artemis-rgb.com/binaries/gh-actions/${{ needs.version.outputs.version-number }}/ - # - name: Prepare Build Info - # run: | - # New-Item -ItemType "Directory" -Path info/ - # $buildId = ${{ needs.version.outputs.version-number }}.Split(".", 2)[1] - # $sha = ${{ github.sha }} - # Set-Content -Path info/latest.json -Value "{ `"BuildId`": $buildId, `"CommitSha`": `"$sha`" }" - # shell: pwsh - # - name: Upload Build Info to FTP - # uses: dennisameling/ftp-upload-action@v1 - # with: - # server: artemis-rgb.com - # username: ${{ secrets.FTP_USER }} - # password: ${{ secrets.FTP_PASSWORD }} - # secure: false - # local_dir: info/ - # server_dir: /builds.artemis-rgb.com/binaries/ \ No newline at end of file + + $body = @{ + "grant_type" = "client_credentials" + "client_id" = "github.task-runners" + "client_secret" = "${{ secrets.UPDATE_SECRET }}" + "scope" = "artemis-updating.releases:retrieve" + } + + $response = Invoke-RestMethod -Method Post -Uri $tokenUri -Body $body -Headers $headers + $accessToken = $response.access_token + + $apiUri = "https://updating.artemis-rgb.com/api/github/retrieve-run/${{ github.run_id }}" + $authHeader = @{ + "Authorization" = "Bearer $accessToken" + } + + $updateResponse = Invoke-RestMethod -Method Post -Uri $apiUri -Headers $authHeader