From 5a49763fd6ecf4d6a1da74876c0145c968ffe50c Mon Sep 17 00:00:00 2001 From: FLYBYME Date: Mon, 4 Dec 2023 22:13:12 -0500 Subject: [PATCH 1/2] Add generateAuthToken function to repositories.service.js --- services/repositories.service.js | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/services/repositories.service.js b/services/repositories.service.js index 54ea1b9..b71535b 100644 --- a/services/repositories.service.js +++ b/services/repositories.service.js @@ -622,6 +622,44 @@ module.exports = { } }, + /** + * generate auth token for repository + * + * @actions + * @param {String} id - id of repository + * + * @returns {String} - repository auth token + */ + generateAuthToken: { + rest: { + method: "GET", + path: "/:id/token", + }, + params: { + id: { + type: "string", + optional: false, + }, + }, + async handler(ctx) { + const params = Object.assign({}, ctx.params); + + // get repository + const repository = await this.getById(ctx, params.id); + + // check repository exists + if (!repository) { + throw new MoleculerClientError("repository not found", 404); + } + + // generate auth token + const authToken = await this.generateAuthToken(ctx, repository); + + // return auth token + return authToken; + } + }, + // clean db clean: { async handler(ctx) { @@ -801,6 +839,25 @@ module.exports = { return repositoryPath; }, + /** + * generate auth token for repository + * + * @param {Context} ctx - context of request + * @param {Object} repository - repository object + * + * @returns {Promise} - repository auth token + */ + async generateAuthToken(ctx, repository) { + // generate auth token + const authToken = await ctx.call('v1.tokens.generate', { + type: 'api-key', + owner: repository.owner, + }); + + // return auth token + return authToken; + }, + }, From da52a451b51dd6f5ecf35f9112c1563e2ea6ceab Mon Sep 17 00:00:00 2001 From: FLYBYME Date: Mon, 4 Dec 2023 22:15:38 -0500 Subject: [PATCH 2/2] Update branch filter in docker-publish workflow --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index c610aea..6662d0b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,7 +7,7 @@ name: Docker on: push: - branches: [ "main", "master", "dev" ] + branches: [ "*" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: