From 2078da51c7e3a4738d36e7a00719f8b8300f35a7 Mon Sep 17 00:00:00 2001 From: Adrien Beaudouin Date: Thu, 22 Aug 2024 19:03:09 +0200 Subject: [PATCH] init auto release project --- docker/action.yaml | 30 +++++++++++++++--------------- release/index.js | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/docker/action.yaml b/docker/action.yaml index f73daa8..2376544 100644 --- a/docker/action.yaml +++ b/docker/action.yaml @@ -20,21 +20,21 @@ inputs: runs: using: composite steps: - - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ inputs.registry }}/${{ gitea.repository }} - - uses: docker/login-action@v3 - with: - registry: ${{ inputs.registry }} - username: ${{ inputs.username }} - password: ${{ inputs.password }} - - uses: docker/build-push-action@v6 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + # - uses: docker/metadata-action@v5 + # id: meta + # with: + # images: ${{ inputs.registry }}/${{ gitea.repository }} + # - uses: docker/login-action@v3 + # with: + # registry: ${{ inputs.registry }} + # username: ${{ inputs.username }} + # password: ${{ inputs.password }} + # - uses: docker/build-push-action@v6 + # with: + # context: . + # push: true + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} - uses: https://gitea.okami101.io/okami101/actions/release@main if: ${{ inputs.release == 'true' }} with: diff --git a/release/index.js b/release/index.js index 2bff25d..f435869 100644 --- a/release/index.js +++ b/release/index.js @@ -10,12 +10,43 @@ async function run() { const [owner, repo] = repository.split("/"); - const gitea_client = new gitea.GiteaApi({ + const client = new gitea.GiteaApi({ BASE: `https://${host}/api/v1`, WITH_CREDENTIALS: true, TOKEN: token, }); + let release = await client.repository.repoGetReleaseByTag({ + owner: owner, + repo: repo, + tag: body.tag_name, + }); + const release_id = release.id; + let target_commitish = release.target_commitish; + if ( + body.target_commitish && + body.target_commitish !== release.target_commitish + ) { + console.log( + `Updating commit from "${release.target_commitish}" to "${body.target_commitish}"` + ); + } + target_commitish = body.target_commitish; + release = client.repository.repoEditRelease({ + owner: owner, + repo: repo, + id: release_id, + body: { + body: body.body || release.body, + draft: body.draft !== undefined ? body.draft : release.draft, + name: body.name || release.name, + prerelease: + body.prerelease !== undefined ? body.prerelease : release.prerelease, + tag_name: body.tag_name || release.tag_name, + target_commitish: target_commitish, + }, + }); + console.log(`TEST ${host} ${token} ${repository} ${owner} ${repo}`); // console.log(`🎉 Release ready at ${response.html_url}`); } catch (error) {