Skip to content

Commit

Permalink
Commit ref
Browse files Browse the repository at this point in the history
  • Loading branch information
manquer committed Apr 8, 2024
1 parent 6f57ad6 commit add2b3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

Expand Down
11 changes: 6 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/gh-ops.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as github from '@actions/github'
import * as core from '@actions/core'

import { GetResponseTypeFromEndpointMethod } from '@octokit/types'
import { get } from 'lodash'
Expand Down Expand Up @@ -53,19 +54,19 @@ export async function commit({ base, workspace }: { base: string; workspace: str
})

if (base) {
await ref(`refs/${get(base.match(new RegExp('(heads)/([a-z]+)')), '0')}`, c.data.sha)
await ref(`${get(base.match(new RegExp('(heads)/([a-z]+)')), '0')}`, c.data.sha)
}
await ref(`refs/tags/v${data.version}`, c.data.sha)
await ref(`tags/v${data.version}`, c.data.sha)
await createRelease(data.version)
await ref(`refs/${get(github.context.ref.match(new RegExp('(heads)/([a-z]+)')), '0')}`, c.data.sha)
await ref(`${get(github.context.ref.match(new RegExp('(heads)/([a-z]+)')), '0')}`, c.data.sha)
return c.data.sha
}

export async function ref(r: string, sha: string): Promise<string> {
const octokit = github.getOctokit(process.env.GITHUB_TOKEN || '')
let res
let ret
console.log(r)
core.info(r)
try {
res = await octokit.rest.git.getRef({
owner: github.context.repo.owner,
Expand All @@ -87,7 +88,7 @@ export async function ref(r: string, sha: string): Promise<string> {
ret = await octokit.rest.git.createRef({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
ref: r,
ref: `refs/${r}`,
sha
})
}
Expand Down

0 comments on commit add2b3c

Please sign in to comment.