mirror of
				https://github.com/ButlerLogic/action-autotag.git
				synced 2025-10-31 07:16:25 +07:00 
			
		
		
		
	Made author optional in changelog message. Fixes #1. Added error handling for github tag API request to handle use case when no tags exist yet. This addresses issue #2.
This commit is contained in:
		
							
								
								
									
										19
									
								
								lib/main.js
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								lib/main.js
									
									
									
									
									
								
							| @ -32,16 +32,21 @@ async function run() { | ||||
|       return | ||||
|     } | ||||
|  | ||||
|     // Check existing for existing tag | ||||
|     // Check for existing tag | ||||
|     const git = new github.GitHub(process.env.INPUT_GITHUB_TOKEN) | ||||
|     const owner = process.env.GITHUB_ACTOR | ||||
|     const repo = process.env.GITHUB_REPOSITORY.split('/').pop() | ||||
|  | ||||
|     let tags = await git.repos.listTags({ | ||||
|       owner, | ||||
|       repo, | ||||
|       per_page: 100 | ||||
|     }) | ||||
|     let tags | ||||
|     try { | ||||
|       tags = await git.repos.listTags({ | ||||
|         owner, | ||||
|         repo, | ||||
|         per_page: 100 | ||||
|       }) | ||||
|     } catch (e) { | ||||
|       tags = {} | ||||
|     } | ||||
|  | ||||
|     // Check for existance of tag and abort (short circuit) if it already exists. | ||||
|     for (let tag of tags.data) { | ||||
| @ -71,7 +76,7 @@ async function run() { | ||||
|           head: 'master' | ||||
|         }) | ||||
|  | ||||
|         tagMsg = changelog.data.commits.map(commit => `**1) ${commit.commit.message}** (${commit.author.login})\n(SHA: ${commit.sha})\n`).join('\n') | ||||
|         tagMsg = changelog.data.commits.map(commit => `**1) ${commit.commit.message}**${commit.hasOwnProperty('author') ? (commit.author.hasOwnProperty('login') ? ' (' + commit.author.login + ')' : '') : ''}\n(SHA: ${commit.sha})\n`).join('\n') | ||||
|       } catch (e) { | ||||
|         core.setFailed(e.message) | ||||
|         return | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Corey Butler
					Corey Butler