UNPKG

@sap/cds-dk

Version:

Command line client and development toolkit for the SAP Cloud Application Programming Model

74 lines (66 loc) 2.3 kB
const path = require('node:path') const { readProject } = require('../../projectReader') const { renderAndCopy } = require('../../template') const cds = require('../../../cds') const { exists, copy } = cds.utils module.exports = class GitHubActionTemplate extends require('../../plugin') { static hasInProduction() { return exists('.github/workflows/test.yaml') } options() { return { 'sap': { type: 'boolean' } } } static help() { return 'CI/CD pipeline via GitHub Actions' } async run() { const out = '.github/workflows/test.yaml' if (!exists(out) || cds.cli.options.force) { await renderAndCopy(path.join(__dirname, 'files/workflows/test.yaml.hbs'), out, { sap: cds.cli.options.sap }) } else { console.log('> skipping ' + out) } } async combine() { const project = readProject() const { hasMta, hasHelm } = project, { force } = cds.cli.options project.literal = () => text => text project.sap = cds.cli.options.sap if (hasMta) { const cf = '.github/workflows/cf.yaml' if (!exists(cf) || force) { await renderAndCopy(path.join(__dirname, 'files/workflows/cf.yaml.hbs'), cf, project) } const cfSetup = '.github/actions/cf-setup' if (!exists(cfSetup) || force) { await copy(path.join(__dirname, 'files/cf-setup'), cfSetup) } const cfGithub = '.github/actions/cf-github-deploy' if (!exists(cfGithub) || force) { await copy(path.join(__dirname, 'files/cf-github-deploy'), cfGithub) } const cfInfo = '.github/actions/cf-info' if (!exists(cfInfo) || force) { await copy(path.join(__dirname, 'files/cf-info'), cfInfo) } } if (hasHelm) { const kyma = '.github/workflows/kyma.yaml' if (!exists(kyma) || force) { await renderAndCopy(path.join(__dirname, 'files/workflows/kyma.yaml.hbs'), kyma, project) } const kymaSetup = '.github/actions/kyma-setup' if (!exists(kymaSetup) || force) { await copy(path.join(__dirname, 'files/kyma-setup'), kymaSetup) } const kymaInfo = '.github/actions/kyma-info' if (!exists(kymaInfo) || force) { await copy(path.join(__dirname, 'files/kyma-info'), kymaInfo) } } } }