Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/create-release-post.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Security Notes
# Only selected Actions are allowed within this repository. Please refer to (https://github.com/nodejs/nodejs.org/settings/actions)
# for the full list of available actions. If you want to add a new one, please reach out a maintainer with Admin permissions.
# REVIEWERS, please always double-check security practices before merging a PR that contains Workflow changes!!
# AUTHORS, please only use actions with explicit SHA references, and avoid using `@master` or `@main` references or `@version` tags.

name: Create Release Blog Post

on:
workflow_dispatch:
inputs:
version:
description: The version to generate a blog post for. If none provided, use the latest release.
type: string

defaults:
run:
# This ensures that the working directory is the root of the repository
working-directory: ./

permissions:
contents: write

jobs:
create-post:
runs-on: ubuntu-latest

steps:
- uses: nodejs/web-team/actions/setup-environment@2c2897a93eb99b4cdca270729100bc0887c758d9
with:
pnpm: true
use-version-file: true

- id: create-release-post
working-directory: apps/site
run: node --run scripts:release-post ${{ inputs.version }}

- name: Open pull request
uses: gr2m/create-or-update-pull-request-action@b65137ca591da0b9f43bad7b24df13050ea45d1b # v1.10.1
# Creates a PR or update the Action's existing PR, or
# no-op if the base branch is already up-to-date.
env:
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
with:
author: Node.js GitHub Bot <github-bot@iojs.org>
branch: release-${{ steps.create-release-post.outputs.version }}
body: |
Creates a new blog post for ${{ steps.create-release-post.outputs.version }}.

Check this workflow's logs at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
commit-message: 'feat(blog): create post for ${{ steps.create-release-post.outputs.version }}'
labels: fast-track
title: 'feat(blog): create post for ${{ steps.create-release-post.outputs.version }}'
update-pull-request-title-and-body: true
14 changes: 11 additions & 3 deletions apps/site/scripts/release-post/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'use strict';

import { existsSync, readFileSync } from 'node:fs';
import { writeFile } from 'node:fs/promises';
import { writeFile, appendFile } from 'node:fs/promises';
import { resolve } from 'node:path';

import handlebars from 'handlebars';
Expand Down Expand Up @@ -234,7 +234,7 @@ const writeToFile = results => {
}

writeFile(blogPostPath, results.content)
.then(() => resolve(blogPostPath))
.then(() => resolve([blogPostPath, results]))
.catch(error => reject(ERRORS.FAILED_FILE_CREATION(error.message)));
});
};
Expand Down Expand Up @@ -263,7 +263,15 @@ if (import.meta.url.startsWith('file:')) {
.then(formatPost)
.then(writeToFile)
.then(
filepath => console.log('Release post created:', filepath),
async ([filepath, { version }]) => {
console.log('Release post created:', filepath);
if (process.env.GITHUB_OUTPUT) {
await appendFile(
process.env.GITHUB_OUTPUT,
`version=v${version}\n`
);
}
},
error => console.error('Some error occurred here!', error.stack)
);
}
Expand Down
Loading