Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix environment-name behaviour (#50, #54) and add Docker support (#46) #55

Merged
merged 18 commits into from
May 14, 2022
Prev Previous commit
Next Next commit
Fix #50
  • Loading branch information
jonashaag committed May 12, 2022
commit 0170eaf02f7b404052b5ad68371c5f1487a590b1
36 changes: 29 additions & 7 deletions dist/main/index.js

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

36 changes: 29 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,40 @@ async function main () {
cacheEnvAlwaysUpdate: false
}

// Read environment file
let envFilePath, envYaml
if (inputs.envFile !== 'false') {
envFilePath = path.join(process.env.GITHUB_WORKSPACE || '', inputs.envFile)
if (!envFilePath.endsWith('.lock')) {
envYaml = yaml.safeLoad(fs.readFileSync(envFilePath, 'utf8'))
}
}

// Read environment file
// Determine environment name
let envName
if (inputs.envFile === 'false') {
if (!inputs.envName) {
if (inputs.envName) {
envName = inputs.envName
} else {
throw Error("Must provide 'environment-name' for 'environment-file: false'")
}
} else {
envFilePath = path.join(process.env.GITHUB_WORKSPACE || '', inputs.envFile)
if (!envFilePath.endsWith('.lock')) {
envYaml = yaml.safeLoad(fs.readFileSync(envFilePath, 'utf8'))
if (envYaml) {
if (inputs.envName) {
envName = inputs.envName
} else {
if (envYaml?.name) {
envName = envYaml?.name
} else {
throw Error("Must provide 'environment-name' if environment.yml doesn't provide a 'name' attribute")
}
}
} else { // .lock file
if (inputs.envName) {
envName = inputs.envName
} else {
throw Error("Must provide 'environment-name' for .lock files")
}
}
}

Expand Down Expand Up @@ -291,8 +314,7 @@ channel_priority: strict
touch(PATHS.bashprofile)

// Install env
const envName = inputs.envName || envYaml?.name
if (envName) {
if (envFilePath || inputs.extraSpecs) {
core.startGroup(`Install environment ${envName} from ${envFilePath || ''} ${inputs.extraSpecs || ''}...`)
let downloadCacheHit, downloadCacheArgs, envCacheHit, envCacheArgs

Expand Down