Skip to content

Commit

Permalink
Added variant to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dapiroy committed Aug 4, 2023
1 parent 01e1987 commit 8787ccb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/actions/build-refs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ outputs:
description: "the ref of the ot3-firmware to use"
build-type:
description: "the type of build oe-core will create (develop, release)"
variant:
description: "internal-release or release"
runs:
using: 'node16'
main: 'dist/index.js'
21 changes: 20 additions & 1 deletion .github/actions/build-refs/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as core from '@actions/core'

export type Repo = 'oe-core' | 'monorepo' | 'ot3-firmware'
export type BuildType = 'develop' | 'release'

export type Variant = 'internal-release' | 'release'
const orderedRepos: Repo[] = ['monorepo', 'oe-core', 'ot3-firmware']

export type Branch = string
Expand Down Expand Up @@ -35,6 +35,22 @@ export interface GitHubApiTag {
ref: Tag
}

function variantForRef(ref: Ref): Variant {
if (ref.startsWith('refs/heads')) {
if (ref.includes('internal-release')) {
return 'internal-release'
} else {
return 'release'
}
} else if (ref.startsWith('refs/tags')) {
if (ref.includes('ot3@')) {
return 'internal-release'
} else if (ref.startsWith('refs/tags/v')) {
return 'release'
}
}
return 'internal-release'
}
function latestTagPrefixFor(repo: Repo): string {
if (repo === 'monorepo') return 'refs/tags/v'
if (repo === 'oe-core') return 'refs/tags/v'
Expand Down Expand Up @@ -222,8 +238,11 @@ async function run() {
// Determine the build-type based on the monorepo ref
if (repo === 'monorepo') {
const buildType = resolveBuildType(ref)
const variant = variantForRef(ref)
core.info(`Resolved oe-core build-type to ${buildType}`)
core.setOutput('build-type', buildType)
core.setOutput('variant', variant)
core.info(`Resolved oe-core variant to ${variant}`)
}
})
}
Expand Down
22 changes: 22 additions & 0 deletions .github/actions/build-refs/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9759,6 +9759,25 @@ function mainRefFor(input) {
function restAPICompliantRef(input) {
return input.replace('refs/', '');
}
function variantForRef(ref) {
if (ref.startsWith('refs/heads')) {
if (ref.includes('internal-release')) {
return 'internal-release';
}
else {
return 'release';
}
}
else if (ref.startsWith('refs/tags')) {
if (ref.includes('ot3@')) {
return 'internal-release';
}
else if (ref.startsWith('refs/tags/v')) {
return 'release';
}
}
return 'internal-release';
}
function latestTagPrefixFor(repo) {
if (repo === 'monorepo')
return 'refs/tags/v';
Expand Down Expand Up @@ -9890,8 +9909,11 @@ function run() {
// Determine the build-type based on the monorepo ref
if (repo === 'monorepo') {
const buildType = resolveBuildType(ref);
const variant = variantForRef(ref);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`Resolved oe-core build-type to ${buildType}`);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('build-type', buildType);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('variant', variant);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.info(`Resolved oe-core variant to ${variant}`);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-ot3-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
build_env: [ '${{ inputs.infra-stage }}' ]
name: 'Building images on ${{ matrix.build_env }}'
timeout-minutes: 480
runs-on: ['self-hosted', '${{matrix.build_env}}']
runs-on: ['self-hosted', '${{matrix.build_env}}', 'internal-release']
steps:
- name: Fetch initial sources for action
uses: 'actions/checkout@v3'
Expand Down

0 comments on commit 8787ccb

Please sign in to comment.