Skip to content

Commit 5c3f453

Browse files
authored
Merge pull request #31 from Telefonica/release
Release v2.0.1
2 parents fcc1ed1 + 2f6183d commit 5c3f453

28 files changed

+33433
-70980
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!package.json
3+
!pnpm-lock.yaml
4+
!bin/
5+
!dist/

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
# may be useful to set it to `true`.
66
ACTIONS_STEP_DEBUG=true
77

8+
# E2E tests
9+
10+
CONFLUENCE_URL=foo-confluence.atlassian.net
11+
CONFLUENCE_PAT=foo-access-token
12+
CONFLUENCE_README_PAGE_ID=foo-readme-page-id
13+
CONFLUENCE_CHANGELOG_PAGE_ID=foo-changelog-page-id
14+
815
# GitHub Actions inputs should follow `INPUT_<name>` format (case-sensitive).
916
# Hyphens should not be converted to underscores!
1017
INPUT_DOCS-DIR="./docs"

.github/CONTRIBUTING.md

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,48 @@ Thank you for being part of the Telefónica Innovación Digital Open Source Comm
2222
1. :hammer_and_wrench: Install the dependencies
2323

2424
```bash
25-
npm install
25+
pnpm install
2626
```
2727

28-
1. :building_construction: Package the TypeScript for distribution
28+
2. :white_check_mark: Run the unit tests
2929

3030
```bash
31-
npm run package
32-
```
33-
34-
1. :white_check_mark: Run the unit tests
35-
36-
```bash
37-
$ npm run test:unit
31+
$ pnpm test:unit
3832

3933
PASS test/unit/specs/main.spec.ts
4034
PASS test/unit/specs/index.spec.ts
4135
...
4236

4337
## Test the action locally
4438

45-
The [`@github/local-action`](https://github.com/github/local-action) utility
46-
can be used to test your action locally. It is a simple command-line tool
47-
that "stubs" (or simulates) the GitHub Actions Toolkit. This way, you can run
48-
your TypeScript action locally without having to commit and push your changes
49-
to a repository.
39+
The action is a Docker container that runs a Node.js script. To test the action locally, you can run the Docker compose file in the root of the repository. This will build the Docker image and run the action in a container.
5040

51-
The `local-action` utility can be run in the following ways:
41+
```bash
42+
$ docker compose build
43+
$ docker compose run action
44+
```
5245

53-
- Visual Studio Code Debugger
46+
> [!CAUTION]
47+
> The Docker image won't work in some systems due to the usage of Chromium, as in MacOS with M1 processors. In this case, you can [run the Node.js code instead](#test-the-nodejs-code-locally).
5448
55-
Make sure to review and, if needed, update
56-
[`.vscode/launch.json`](./.vscode/launch.json)
49+
You can provide a `.env` file to set environment variables used by the GitHub Actions Toolkit. For more information, see the example file, [`.env.example`](./.env.example), and the
50+
[GitHub Actions Documentation](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables).
5751
58-
- Terminal/Command Prompt
52+
> [!IMPORTANT]
53+
> The root workspace directory is mounted as a volume in the container in the `/github/workspace` folder. You can set another workspace subdirectory for testing the synchronization locally by setting the `INPUT_CWD` environment variable to the desired directory (e.g. `INPUT_CWD=test-action`).
5954
60-
```bash
61-
# npx local action <action-yaml-path> <entrypoint> <dotenv-file>
62-
npx local-action . src/main.ts .env
63-
```
55+
### Test the Node.js code locally
6456
65-
You can provide a `.env` file to the `local-action` CLI to set environment
66-
variables used by the GitHub Actions Toolkit. For more information, see the example
67-
file, [`.env.example`](./.env.example), and the
68-
[GitHub Actions Documentation](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables).
57+
Apart from running the unit tests, you can also run the Node.js code locally by following these steps:
58+
59+
* Modify the `src/action/main.ts` file to change the `BASE_CWD` variable from `/github/workspace` to the desired directory (e.g. `test-action`).
60+
* Build the action code using the `pnpm build` command.
61+
* Add your markdown file and configuration files to the desired directory (e.g. `test-action/markdown-confluence-sync.config.js` and `test-action/docs/foo.md`).
62+
* Run the action code using `node bin/markdown-confluence-sync-action.js`.
6963
7064
## E2E tests
7165
72-
This project includes end-to-end tests, consisting in a workflow that uses the action to sync the documentation of the project itself to a Confluence page, and then checks if the page was updated correctly.
66+
This project includes end-to-end tests, consisting in a workflow that uses the action to sync the documentation of the project itself to a Confluence page, and then checks if the page was updated correctly. Once the documentation has been synced, you can run tests using the following command:
7367
7468
```bash
7569
npm run test:e2e
@@ -111,32 +105,40 @@ But we use the __merge commit strategy for merging PRs to the main branch from t
111105
112106
# Release process
113107
114-
Once the PR is approved and merged into the main branch, a project maintainer can start the release process by tagging the main branch with the corresponding version numbers.
115-
116-
This project includes a helper script, [`script/release`](./script/release)
117-
designed to streamline the process of tagging and pushing new releases for
118-
GitHub Actions.
119-
120-
GitHub Actions allows users to select a specific version of the action to use,
121-
based on release tags. This script simplifies this process by performing the
122-
following steps:
123-
124-
1. **Retrieving the latest release tag:** The script starts by fetching the most
125-
recent SemVer release tag of the current branch, by looking at the local data
126-
available in your repository.
127-
1. **Prompting for a new release tag:** The user is then prompted to enter a new
128-
release tag. To assist with this, the script displays the tag retrieved in
129-
the previous step, and validates the format of the inputted tag (vX.X.X). The
130-
user is also reminded to update the version field in package.json.
131-
1. **Tagging the new release:** The script then tags a new release and syncs the
132-
separate major tag (e.g. v1, v2) with the new release tag (e.g. v1.0.0,
133-
v2.1.2). When the user is creating a new major release, the script
134-
auto-detects this and creates a `releases/v#` branch for the previous major
135-
version.
136-
1. **Pushing changes to remote:** Finally, the script pushes the necessary
137-
commits, tags and branches to the remote repository. From here, you will need
138-
to create a new release in GitHub so users can easily reference the new tags
139-
in their workflows.
108+
Once the PR is approved and __merged into the release branch__, a project maintainer can start the release process by:
109+
110+
1. Checking the version number in the `package.json` file and updating it if necessary.
111+
2. Checking the action version in the `.github/actions/check-and-comment/action.yml` file and updating it if necessary.
112+
3. Updating the CHANGELOG.md file with the changes in the new version.
113+
4. Remove the beta tags created for the PR check.
114+
5. Tagging the release branch with the corresponding version numbers.
115+
116+
This project includes a helper script, [`script/release`](./script/release)
117+
designed to streamline the process of tagging and pushing new releases for
118+
GitHub Actions.
119+
120+
GitHub Actions allows users to select a specific version of the action to use,
121+
based on release tags. This script simplifies this process by performing the
122+
following steps:
123+
124+
1. **Retrieving the latest release tag:** The script starts by fetching the most
125+
recent SemVer release tag of the current branch, by looking at the local data
126+
available in your repository.
127+
2. **Prompting for a new release tag:** The user is then prompted to enter a new
128+
release tag. To assist with this, the script displays the tag retrieved in
129+
the previous step, and validates the format of the inputted tag (vX.X.X). The
130+
user is also reminded to update the version field in package.json.
131+
3. **Tagging the new release:** The script then tags a new release and syncs the
132+
separate major tag (e.g. v1, v2) with the new release tag (e.g. v1.0.0,
133+
v2.1.2). When the user is creating a new major release, the script
134+
auto-detects this and creates a `releases/v#` branch for the previous major
135+
version.
136+
4. **Pushing changes to remote:** Finally, the script pushes the necessary
137+
commits, tags and branches to the remote repository. From here, you will need
138+
to create a new release in GitHub so users can easily reference the new tags
139+
in their workflows.
140+
6. Create a new release in GitHub with the tag created in the previous step and the changes in the CHANGELOG.md file.
141+
7. Merge the release branch into the main branch.
140142
141143
# License
142144

.github/actions/setup-node/action.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ inputs:
1212
runs:
1313
using: composite
1414
steps:
15-
- name: Setup Node.js
16-
id: setup-node
15+
- name: Install pnpm
16+
uses: pnpm/action-setup@v4
17+
- name: Install Node.js
1718
uses: actions/setup-node@v4
1819
with:
1920
node-version-file: .node-version
20-
cache: npm
21+
cache: pnpm
2122
- uses: DamianReeves/[email protected]
2223
with:
2324
path: .npmrc
2425
contents: |
2526
@tid-xcut:registry=https://nexus.tid.es/repository/npm-xcut-components/
2627
//nexus.tid.es/repository/npm-xcut-components/:_auth=${{ inputs.npm-token }}
2728
write-mode: append
28-
- name: Install Dependencies
29+
- name: Install Node.js dependencies
2930
shell: bash
30-
id: npm-ci
31-
run: npm ci
31+
run: pnpm install

.github/workflows/build.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,25 @@ jobs:
2828
with:
2929
npm-token: ${{ secrets.NPM_TOKEN_XCUT }}
3030

31+
- name: Build
32+
id: build
33+
run: pnpm build
34+
3135
- name: Lint
3236
id: npm-lint
33-
run: npm run lint
37+
run: pnpm lint
3438

3539
- name: Check spelling
3640
id: npm-check-spelling
37-
run: npm run cspell
41+
run: pnpm cspell
3842

3943
- name: Check TypeScript types
4044
id: npm-check-types
41-
run: npm run check:types
45+
run: pnpm check:types
4246

4347
- name: Test unit
4448
id: npm-test
45-
run: npm run test:unit
46-
47-
- name: Upload coverage
48-
id: upload-coverage
49-
uses: actions/upload-artifact@v4
50-
with:
51-
name: coverage
52-
path: coverage/
53-
54-
- name: Build dist/ Directory
55-
id: build
56-
run: npm run package
49+
run: pnpm test:unit
5750

5851
# This will fail the workflow if the `dist/` directory is different than
5952
# expected.
@@ -80,3 +73,10 @@ jobs:
8073
with:
8174
name: dist
8275
path: dist/
76+
77+
- name: Upload coverage
78+
id: upload-coverage
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: coverage
82+
path: coverage/

.github/workflows/test-e2e.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
with:
2929
mode: id
3030
docs-dir: '.'
31+
confluence-notice-message: 'This page is automatically generated from content in the <a href="https://github.com/Telefonica/markdown-confluence-sync-action" target="_blank">markdown-confluence-sync-action repository</a> Changes made manually will be lost, you should edit this page in Github instead.'
3132
files-pattern: '*.md'
3233
files-metadata: |
3334
[
@@ -45,6 +46,7 @@ jobs:
4546
confluence-url: ${{ vars.CONFLUENCE_URL }}
4647
confluence-space-key: ${{ vars.CONFLUENCE_SPACE_KEY }}
4748
confluence-personal-access-token: ${{ secrets.CONFLUENCE_PAT }}
49+
log-level: debug
4850

4951
test-e2e:
5052
environment: production

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
node_modules
33
.npmrc
44

5+
# Test action locally
6+
test-action
7+
58
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
69
# Logs
710
logs

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
#### Deprecated
1212
#### Removed
1313

14+
## [2.0.1] - 2025-03-18
15+
16+
### Changed
17+
18+
* chore(deps): Bump @tid-xcut/markdown-confluence-sync from 1.1.0 to 1.1.1 (Fix preprocess hook)
19+
* docs: Improve release process guide in CONTRIBUTING.md
20+
21+
## [2.0.0] - 2025-03-18
22+
23+
### Changed
24+
25+
* feat(BREAKING CHANGE): Throw an error in case the `cwd` input is absolute, because the action only has access to the repository files
26+
* chore: Use Docker action instead of Node.js action in order to install Chromium and Puppeteer
27+
* chore: Use Pnpm instead of NPM
28+
* chore: Move `dependencies` to `devDependencies`, because in runtime the action uses only the bundled code, and it installs the mermaid dependencies by itself in the Docker image. This is because the `@tid-xcut` libraries are in a private repository, and the action cannot install them in the Docker image. Some fixes are applied to the bundled code to make it work in the Docker image.
29+
30+
### Fixed
31+
32+
* fix: Generate mermaid diagrams in the Confluence page
33+
34+
### Added
35+
36+
* docs: Add automation notice to Confluence pages containing the action docs
37+
* test: Add mermaid diagram to readme.md file, and test that it has been synced to Confluence in E2E tests
38+
39+
1440
## [1.2.0] - 2025-03-13
1541

1642
### Changed

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM --platform=linux/amd64 node:22
2+
RUN corepack enable && corepack prepare [email protected] --activate
3+
4+
# We don't need the standalone Chromium
5+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
6+
ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium"
7+
8+
# cspell: disable
9+
# Install Google Chrome Stable and fonts
10+
# Note: this installs the necessary libs to make the browser work with Puppeteer, and the fonts needed for Mermaid
11+
RUN apt-get update && apt-get install curl gnupg -y \
12+
&& curl --location --silent https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
13+
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
14+
&& apt-get update \
15+
&& apt-get install google-chrome-stable -y --no-install-recommends \
16+
&& apt-get install chromium -y \
17+
&& apt-get install -y \
18+
fonts-noto-cjk fonts-noto-color-emoji \
19+
fonts-terminus fonts-dejavu fonts-freefont-ttf \
20+
fonts-font-awesome fonts-inconsolata \
21+
fonts-linuxlibertine \
22+
&& fc-cache -f \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# NOTE: We need to install Mermaid globally, as we are not installing the package.json dependencies due to private packages
26+
RUN npm i -g [email protected] @mermaid-js/[email protected]
27+
28+
WORKDIR /usr/src/app
29+
30+
COPY . .
31+
32+
ENTRYPOINT [ "node", "/usr/src/app/bin/markdown-confluence-sync-action.js"]

0 commit comments

Comments
 (0)