Skip to content

Commit

Permalink
Upgrade to support wing platforms (at least v0.44)
Browse files Browse the repository at this point in the history
  • Loading branch information
skorfmann committed Nov 3, 2023
1 parent d459767 commit 2f5a019
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 70 deletions.
2 changes: 1 addition & 1 deletion actions/deploy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FROM ghcr.io/winglang/wing-github-action:main

RUN mkdir /action
COPY ./dist /action/dist
COPY ./plugins /action/plugins
COPY ./platforms /action/platforms

ENTRYPOINT ["node", "/action/dist/index.js"]
8 changes: 4 additions & 4 deletions actions/deploy/dist/index.js

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

2 changes: 1 addition & 1 deletion actions/deploy/dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions actions/deploy/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ function run() {
core.info(`Injecting backend config for S3`);
yield (0, utils_1.runCommand)('wing', [
'compile',
'--plugins',
'/action/plugins/backend.s3.js',
'-t',
'--platform',
target,
'--platform',
'/action/platforms/backend.s3.js',
entrypoint
], {
env: Object.assign(Object.assign({}, tfEnv), { TF_BACKEND_STATE_FILE: (0, utils_1.stateFile)() })
});
}
else {
yield (0, utils_1.runCommand)('wing', ['compile', '--debug', '-t', target, entrypoint]);
yield (0, utils_1.runCommand)('wing', ['compile', '--debug', '--platform', target, entrypoint]);
}
const tfWorkDir = path.join(process.cwd(), workdir, 'target', `${main}.${target.replace('-', '')}`);
yield (0, utils_1.runCommand)('terraform', ['init'], {
Expand Down
21 changes: 21 additions & 0 deletions actions/deploy/platforms/backend.s3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* - TF_BACKEND_BUCKET - The name of the s3 bucket to use for storing Terraform state
* - TF_BACKEND_BUCKET_REGION - The region the bucket was deployed to
* - TF_BACKEND_STATE_FILE - The object key used to store state file
*/

exports.Platform = class WingGithubActionsBackendS3 {
postSynth(config) {
if (!process.env.TF_BACKEND_BUCKET) {throw new Error("env var TF_BACKEND_BUCKET not set")}
if (!process.env.TF_BACKEND_BUCKET_REGION) {throw new Error("env var TF_BACKEND_BUCKET_REGION not set")}
if (!process.env.TF_BACKEND_STATE_FILE) {throw new Error("env var TF_BACKEND_STATE_FILE not set")}
config.terraform.backend = {
s3: {
bucket: process.env.TF_BACKEND_BUCKET,
region: process.env.TF_BACKEND_BUCKET_REGION,
key: process.env.TF_BACKEND_STATE_FILE
}
}
return config;
}
}
21 changes: 0 additions & 21 deletions actions/deploy/plugins/backend.s3.js

This file was deleted.

8 changes: 4 additions & 4 deletions actions/deploy/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ async function run(): Promise<void> {
'wing',
[
'compile',
'--plugins',
'/action/plugins/backend.s3.js',
'-t',
'--platform',
target,
'--platform',
'/action/platforms/backend.s3.js',
entrypoint
],
{
Expand All @@ -76,7 +76,7 @@ async function run(): Promise<void> {
}
)
} else {
await runCommand('wing', ['compile', '--debug', '-t', target, entrypoint])
await runCommand('wing', ['compile', '--debug', '--platform', target, entrypoint])
}

const tfWorkDir = path.join(
Expand Down
2 changes: 1 addition & 1 deletion actions/pull-request-diff/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FROM ghcr.io/winglang/wing-github-action:main

RUN mkdir /action
COPY ./dist /action/dist
COPY ./plugins /action/plugins
COPY ./platforms /action/platforms

ENTRYPOINT ["node", "/action/dist/index.js"]
8 changes: 4 additions & 4 deletions actions/pull-request-diff/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ function run() {
core.info(`Injecting backend config for S3`);
yield (0, utils_1.runCommand)('wing', [
'compile',
'--plugins',
'/action/plugins/backend.s3.js',
'-t',
'--platform',
target,
'--platform',
'/action/platforms/backend.s3.js',
entrypoint
], {
env: Object.assign(Object.assign({}, tfEnv), { TF_BACKEND_STATE_FILE: (0, utils_1.stateFile)(process.env.GITHUB_BASE_REF) })
});
}
else {
yield (0, utils_1.runCommand)('wing', ['compile', '--debug', '-t', target, entrypoint]);
yield (0, utils_1.runCommand)('wing', ['compile', '--debug', '--platform', target, entrypoint]);
}
const tfWorkDir = path.join(process.cwd(), workdir, 'target', `${main}.${target.replace('-', '')}`);
yield (0, utils_1.runCommand)('terraform', ['init'], {
Expand Down
2 changes: 1 addition & 1 deletion actions/pull-request-diff/dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions actions/pull-request-diff/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ function run() {
core.info(`Injecting backend config for S3`);
yield (0, utils_1.runCommand)('wing', [
'compile',
'--plugins',
'/action/plugins/backend.s3.js',
'-t',
'--platform',
target,
'--platform',
'/action/platforms/backend.s3.js',
entrypoint
], {
env: Object.assign(Object.assign({}, tfEnv), { TF_BACKEND_STATE_FILE: (0, utils_1.stateFile)(process.env.GITHUB_BASE_REF) })
});
}
else {
yield (0, utils_1.runCommand)('wing', ['compile', '--debug', '-t', target, entrypoint]);
yield (0, utils_1.runCommand)('wing', ['compile', '--debug', '--platform', target, entrypoint]);
}
const tfWorkDir = path.join(process.cwd(), workdir, 'target', `${main}.${target.replace('-', '')}`);
yield (0, utils_1.runCommand)('terraform', ['init'], {
Expand Down
21 changes: 21 additions & 0 deletions actions/pull-request-diff/platforms/backend.s3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* - TF_BACKEND_BUCKET - The name of the s3 bucket to use for storing Terraform state
* - TF_BACKEND_BUCKET_REGION - The region the bucket was deployed to
* - TF_BACKEND_STATE_FILE - The object key used to store state file
*/

exports.Platform = class WingGithubActionsBackendS3 {
postSynth(config) {
if (!process.env.TF_BACKEND_BUCKET) {throw new Error("env var TF_BACKEND_BUCKET not set")}
if (!process.env.TF_BACKEND_BUCKET_REGION) {throw new Error("env var TF_BACKEND_BUCKET_REGION not set")}
if (!process.env.TF_BACKEND_STATE_FILE) {throw new Error("env var TF_BACKEND_STATE_FILE not set")}
config.terraform.backend = {
s3: {
bucket: process.env.TF_BACKEND_BUCKET,
region: process.env.TF_BACKEND_BUCKET_REGION,
key: process.env.TF_BACKEND_STATE_FILE
}
}
return config;
}
}
21 changes: 0 additions & 21 deletions actions/pull-request-diff/plugins/backend.s3.js

This file was deleted.

8 changes: 4 additions & 4 deletions actions/pull-request-diff/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ async function run(): Promise<void> {
'wing',
[
'compile',
'--plugins',
'/action/plugins/backend.s3.js',
'-t',
'--platform',
target,
'--platform',
'/action/platforms/backend.s3.js',
entrypoint
],
{
Expand All @@ -100,7 +100,7 @@ async function run(): Promise<void> {
}
)
} else {
await runCommand('wing', ['compile', '--debug', '-t', target, entrypoint])
await runCommand('wing', ['compile', '--debug', '--platform', target, entrypoint])
}

const tfWorkDir = path.join(
Expand Down

0 comments on commit 2f5a019

Please sign in to comment.