diff --git a/.changeset/revert-js-yaml-4x.md b/.changeset/revert-js-yaml-4x.md new file mode 100644 index 00000000..4d56b1c0 --- /dev/null +++ b/.changeset/revert-js-yaml-4x.md @@ -0,0 +1,5 @@ +--- +"@slack/slack-github-action": patch +--- + +fix: revert multiline yaml parsing indentation change diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index db008d92..bfb183c1 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -103,6 +103,24 @@ jobs: env: MESSAGE_OUTPUT_TS: ${{ steps.message.outputs.ts }} + - name: "test(api): post a multiline message" # https://github.com/slackapi/slack-github-action/issues/637 + id: multiline + uses: ./ + with: + errors: true + method: chat.postMessage + token: ${{ secrets.SLACK_BOT_TOKEN }} + payload: | + channel: ${{ secrets.SLACK_CHANNEL_ID }} + text: ":checkered_flag: A multiline message wraps across lines + + with a blank line before " + + - name: "test(api): confirm the multiline message was posted" + run: test -n "$MULTILINE_OUTPUT_TS" + env: + MULTILINE_OUTPUT_TS: ${{ steps.multiline.outputs.ts }} + - name: "test(api): post a message with blocks" id: blocks uses: ./ diff --git a/package-lock.json b/package-lock.json index 85170ee4..1b8d388a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,13 +16,14 @@ "@slack/webhook": "^7.2.0", "flat": "^6.0.1", "https-proxy-agent": "^9.0.0", - "js-yaml": "^5.2.0", + "js-yaml": "^4.2.0", "markup-js": "^1.5.21" }, "devDependencies": { "@biomejs/biome": "^2.5.1", "@changesets/cli": "^2.31.0", "@types/flat": "^5.0.5", + "@types/js-yaml": "^4.0.9", "@types/markup-js": "^1.5.0", "@types/node": "^24.13.2", "@types/sinon": "^21.0.0", @@ -462,29 +463,6 @@ "js-yaml": "^4.1.1" } }, - "node_modules/@changesets/parse/node_modules/js-yaml": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz", - "integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/puzrin" - }, - { - "type": "github", - "url": "https://github.com/sponsors/nodeca" - } - ], - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/@changesets/pre": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@changesets/pre/-/pre-2.0.2.tgz", @@ -943,6 +921,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/js-yaml": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", + "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/markup-js": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@types/markup-js/-/markup-js-1.5.0.tgz", @@ -1701,9 +1686,9 @@ "license": "ISC" }, "node_modules/js-yaml": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.2.0.tgz", - "integrity": "sha512-YeLUMlvR4Ou1B119LIaM0r65JvbOBooJDc9yEu0dClb/uSC5P4FrLU8OCCz/HXWvtPoIrR0dRzABTjo1sTN9Bw==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz", + "integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==", "funding": [ { "type": "github", @@ -1719,7 +1704,7 @@ "argparse": "^2.0.1" }, "bin": { - "js-yaml": "bin/js-yaml.mjs" + "js-yaml": "bin/js-yaml.js" } }, "node_modules/jsonfile": { diff --git a/package.json b/package.json index 0a3f6015..c1a3153c 100644 --- a/package.json +++ b/package.json @@ -49,13 +49,14 @@ "@slack/webhook": "^7.2.0", "flat": "^6.0.1", "https-proxy-agent": "^9.0.0", - "js-yaml": "^5.2.0", + "js-yaml": "^4.2.0", "markup-js": "^1.5.21" }, "devDependencies": { "@biomejs/biome": "^2.5.1", "@changesets/cli": "^2.31.0", "@types/flat": "^5.0.5", + "@types/js-yaml": "^4.0.9", "@types/markup-js": "^1.5.0", "@types/node": "^24.13.2", "@types/sinon": "^21.0.0", diff --git a/test/content.spec.js b/test/content.spec.js index 5288d61b..7704afd0 100644 --- a/test/content.spec.js +++ b/test/content.spec.js @@ -71,6 +71,21 @@ describe("content", () => { assert.deepEqual(config.content.values, expected); }); + /** + * @see {@link https://github.com/slackapi/slack-github-action/issues/637} + */ + it("parses multiline YAML from the input payload", async () => { + mocks.core.getInput + .withArgs("payload") + .returns('channel: C0123456789\ntext: "first line\n\nsecond line"'); + const config = new Config(mocks.core); + const expected = { + channel: "C0123456789", + text: "first line\nsecond line", + }; + assert.deepEqual(config.content.values, expected); + }); + it("parses complete JSON from the input payload", async () => { mocks.core.getInput.withArgs("payload").returns(`{ "message": "this is wrapped",