Skip to content
Open
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5eee76d
Working on an asciidoc action
dfoulks1 Nov 26, 2024
caa4df7
Use node to install and not apt
dfoulks1 Nov 26, 2024
088342e
No package file present yet, install packages by name
dfoulks1 Nov 26, 2024
e7254b1
use bash to ls files
dfoulks1 Nov 26, 2024
c3d2f25
look for convert.js in the action path, not in the repo
dfoulks1 Nov 26, 2024
2f2bbb3
Updated the installed package list
dfoulks1 Nov 26, 2024
d2996d0
Updated the installed package list again
dfoulks1 Nov 26, 2024
4b1d544
convert-slides.js needs to be in the same directory as the adoc?
dfoulks1 Nov 26, 2024
03a9f1e
missing quotes on variables
dfoulks1 Nov 26, 2024
08ed942
Better quotes this time
dfoulks1 Nov 26, 2024
e84241f
split up the environment set up and the actual node command
dfoulks1 Nov 26, 2024
50227f2
working on getting paths correct
dfoulks1 Nov 26, 2024
745a16d
Working with the default directory
dfoulks1 Nov 26, 2024
2bed37c
Working with the default directory directive
dfoulks1 Nov 26, 2024
bd92ead
directive typo
dfoulks1 Nov 26, 2024
bd5644a
fixed variable name
dfoulks1 Nov 26, 2024
4ad7b6d
added echo and modified the bash capture
dfoulks1 Nov 26, 2024
1ec87e9
Tweaked action order
dfoulks1 Nov 26, 2024
b12b4b2
Testing ordering and working directory
dfoulks1 Nov 26, 2024
3b2aae7
Generating asciidocs works
dfoulks1 Nov 26, 2024
96af62a
Added some file extension checking
dfoulks1 Nov 26, 2024
f4956dc
Missed bash if ending
dfoulks1 Nov 26, 2024
088cf57
Bash syntax is not python syntax
dfoulks1 Nov 26, 2024
81127a9
Bash syntax is still not python syntax
dfoulks1 Nov 26, 2024
873156e
Changed default tempdir
dfoulks1 Nov 26, 2024
2898a38
Switched order to verify tempdir is being created
dfoulks1 Nov 26, 2024
264fa6f
Fixed next step
dfoulks1 Nov 26, 2024
54d2010
Updated dest_branch name
dfoulks1 Nov 26, 2024
e4a527f
Set the working directory for all steps
dfoulks1 Nov 26, 2024
711c2c6
Omit the working directory directive to return to the root of the repo
dfoulks1 Nov 26, 2024
ab58dae
Fill path to tempdir
dfoulks1 Nov 26, 2024
c630afb
Added an ls check for the temp dir
dfoulks1 Nov 26, 2024
c58beac
Booped the basename match regex
dfoulks1 Nov 26, 2024
7a671e6
Working on getting the node packages in the correct directory
dfoulks1 Nov 27, 2024
0f07ba2
Working on getting the node packages in the correct directory this ti…
dfoulks1 Nov 27, 2024
213669c
typofix
dfoulks1 Nov 27, 2024
eca9cda
Use reveal
dfoulks1 Nov 27, 2024
3fbbd2d
copy package.json
dfoulks1 Nov 27, 2024
1a604d1
Ensure asciidoc core is in package.json
dfoulks1 Nov 27, 2024
6f01bdc
Pass along the packages.json for presenting
dfoulks1 Nov 27, 2024
e0612f9
not worrying about installing node in srcfiles path
dfoulks1 Nov 27, 2024
1e76ebd
whitespace typo
dfoulks1 Nov 27, 2024
7053581
copy package.json from action, not repo
dfoulks1 Nov 27, 2024
3f4156e
Copy statis assets and remove debug ls
dfoulks1 Nov 27, 2024
6dca734
Added CSS and images
dfoulks1 Nov 27, 2024
0b2c8c5
Removed static path in the action, all static stuff now comes from th…
dfoulks1 Nov 27, 2024
062d8ae
Action tries to copy the static dir from teh workspace
dfoulks1 Nov 27, 2024
9d42ac9
Used wrong var by mistake
dfoulks1 Nov 27, 2024
b2b1e83
Action assumes working in the workspace already no need for explicit def
dfoulks1 Nov 27, 2024
452d3ad
Now do all of that _before_ chanign the branch
dfoulks1 Nov 27, 2024
a8edeea
basic logic check to get around the issue
dfoulks1 Nov 27, 2024
d98ed62
Added a a debug
dfoulks1 Nov 27, 2024
ed3e27f
Dont suppress debug output yet
dfoulks1 Nov 27, 2024
bd2cd16
Copy the static assets explicitly
dfoulks1 Nov 27, 2024
5a1a8ec
typodix
dfoulks1 Nov 27, 2024
ed671d1
Static into the tempdir
dfoulks1 Nov 27, 2024
17108ea
typofix
dfoulks1 Nov 27, 2024
66d3e2e
Added a step to locate provided assets directory
dfoulks1 Dec 3, 2024
1da446c
Still working on getting a specified static dir to get moved with the…
dfoulks1 Dec 3, 2024
2f608dd
botched the path, now it goes into tempdir and not outputdir
dfoulks1 Dec 3, 2024
f553880
Cleaned up a bit, would like to divine the name of the assets dir in …
dfoulks1 Dec 3, 2024
3989dc2
Apply suggestions from code review
dfoulks1 Dec 5, 2024
f52a17e
asciidoc example
dfoulks1 Jan 6, 2025
d45f602
Streamlining asciidoc action to push straight to ghpages
dfoulks1 Feb 10, 2025
f4d1059
Merge branch 'dfoulks/asciidoc' of github.com:apache/infrastructure-a…
dfoulks1 Feb 10, 2025
15747a1
Added shell to the run command to install npm in the artifact
dfoulks1 Feb 10, 2025
1af72cc
OF: Indentation typo
dfoulks1 Feb 10, 2025
c22adb5
Added Working Directory to the npm install in lieu of a relative
dfoulks1 Feb 10, 2025
2c2fb7b
action.yml no longer needs the tempdir as it's no longer pushing to a…
dfoulks1 Feb 10, 2025
cd362ac
Attempting to set the working dir as srcdir/output instead of moving …
dfoulks1 Feb 10, 2025
d1c09a4
Updated workflow permissions to include pages
dfoulks1 Feb 10, 2025
92ff2dd
Dialing back perms
dfoulks1 Feb 10, 2025
d6cabc6
Adding permissions elsewhere
dfoulks1 Feb 10, 2025
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
3 changes: 3 additions & 0 deletions asciidoc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

node_modules/*
package-lock.json
102 changes: 102 additions & 0 deletions asciidoc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Build Presentations with AsciiDoc
description: "Generate a Slidedeck from AsciiDoc Markdown"
inputs:
srcdir:
description: "AsciiDoc sourcefile directory"
required: false
default: "srcfiles"
assets:
description: "Site assets directory"
required: false
default: "static"
dest_branch:
description: "Slidedeck Output branch"
required: false
default: "presentations"
publish:
description: "Publish the site to the destination branch. If false, the site is built but not published."
required: false
default: "true"
output:
description: "AsciiDoc output directory"
required: false
default: 'output'
tempdir:
description: "Temporary Directory name"
required: false
default: 'output.tmp'
debug:
description: "AsciiDoc Debug mode"
required: false
default: 'false'
runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/setup-node@v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0

While it's an offical action and this doesn't require pinning in workflows I think it still makes sense within an action as the user has no control over it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would there be a way to test this / keep this hash up to date with dependabot or something? Trying to prevent having to touch this everytime there's an update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes dependabot can do it, just add the dir with action.yml to the directories list in dependabot.yml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would pin all actions also the ones coming from GitHub. The positive side effect is that your action does not have uncertainty wrt which exact action is being used. We have seen in the past that sometimes bugs are introduces in newly released versions and when you use just @v4 you will always get the latest released version of the v4 branch of that action. Having it pinned to an exact version makes actions more stable imho.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw. you can use https://github.com/eclipse-csi/octopin for pinning.

install with pipx install octocpin

- name: Install AsciiDoc
shell: bash
# Install needs to run in separate shell so stdout is restored
run: |
(
test "${{ inputs.debug }}" == 'true' || exec >/dev/null
npm install
)
# working-directory: "${{ inputs.srcdir }}"
working-directory: "${{ github.action_path }}"

- name:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please name your steps

shell: bash
run: |
mkdir "${{ inputs.tempdir }}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir "${{ inputs.tempdir }}"
: 'Some name for this step -- the same as the `name:` field -- so that users see this instead of just the first rather useless line of the step when looking at a workflow'
mkdir "${{ inputs.tempdir }}"

ln -s "${{ github.action_path }}/convert-slides.js" .
for file in `ls`; do
if [[ "$(echo $file | awk -F. '{print $NF}')" != "adoc" ]]; then
continue
fi
echo $file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was all ripped from the pelican action. If there's a better / more GHA way to approach this, I'm 100% interested.

node convert-slides.js $file
mv $(basename $file .adoc).html "${{ inputs.tempdir }}"/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mv $(basename $file .adoc).html "${{ inputs.tempdir }}"/
mv $(basename $file).html "${{ inputs.tempdir }}"/

Or did that serve a purpose there? I think it would just be dropped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the basename command requires a suffix to strip.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah that makes sense, if never needed that before :D

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never use ${{ ... }} inside a run: block.

Always use:

env:
  tempdir: ${{ inputs.tempdir }}
run: |
  ...
  echo "$tempdir"

done
cp "${{ github.action_path }}/package.json" "${{ inputs.tempdir }}"
[ -d "${{ github.workspace }}/${{ inputs.assets }}" ] && cp -r "${{ github.workspace }}/${{ inputs.assets }}" "${{ inputs.tempdir }}" || echo "No ${{ inputs.assets }} found!"
working-directory: "${{ inputs.srcdir }}"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an actions/upload-artifact step here if: ${{ inputs.publish != 'true' }} (or rather if: inputs.publish if you make it a boolean. I'll add a comment above).

That way you could check the created artifacts when running the action in a PR or something. (and we can use it in testing)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use to if: toJSON(inputs.publish) or something like that

- name: Check out previous branch
if: ${{ inputs.publish == 'true' }}
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "AsciiDcotor (action)"
git remote update
if git checkout "${{ inputs.dest_branch }}"
then
git pull origin "${{ inputs.dest_branch }}"
else
# if none, create it.
echo "branch ${{ inputs.dest_branch }} is new; create empty site"
git switch --orphan "${{ inputs.dest_branch }}"
git checkout "origin/${{ github.ref_name }}" -- .asf.yaml
git add .asf.yaml -f
git commit -m "Initialise empty site"
git push -u origin "${{ inputs.dest_branch }}"
fi
working-directory: "${{ inputs.srcdir }}"

- name: Commit Directly to the branch
if: ${{ inputs.publish == 'true' }}
shell: bash
run: |
# Remove all existing output so deletions will be captured
rm -rf "${{ inputs.output }}"
git rm --quiet -r --ignore-unmatch --cached "${{ inputs.output }}"/*
mv "${{ inputs.srcdir }}/${{ inputs.tempdir }}" "${{ inputs.output }}"
git diff # Show changes
git add "${{ inputs.output }}"
git status
if git commit -m "Commit build products"
then
git push
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this will fail as you are not setting up auth via actions/checkout or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was pulled from the pelican action and has been tested against the infrastructure-presentations repo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the workflow using the pelican action called actions/checkout then.

You could make it a usage requirement to use this within an existing checkout but that should be documented specifically requiring that persist-credentials: is set to true otherwise this will fail.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling the input publish instead of pushToBranch is unfortunate.

else
echo "No change"
true # ensure step is successful
fi
9 changes: 9 additions & 0 deletions asciidoc/convert-slides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Run syntax: node convert-slides.js filename.adoc
// Load Asciidoctor.js and the reveal.js converter
var asciidoctor = require('@asciidoctor/core')()
var asciidoctorRevealjs = require('@asciidoctor/reveal.js')
asciidoctorRevealjs.register()

// Convert the document 'presentation.adoc' using the reveal.js converter
var options = { safe: 'safe', backend: 'revealjs' }
asciidoctor.convertFile(process.argv[2], options)
8 changes: 8 additions & 0 deletions asciidoc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"@asciidoctor/core": "^3.0.4",
"@asciidoctor/reveal.js": "^5.1.0",
"asciidoctor": "^3.0.4",
"reveal": "^0.0.4"
}
}
Loading