Skip to content

Commit

Permalink
BREAKING CHANGE: Use body replacement instead of details/summary or H…
Browse files Browse the repository at this point in the history
…TML comments (#11)

* Use header/footer to update

* move back env

* Update action.yml

* quote to keep newlines

* Update action.yml

* Update action.yml

* Update README.md

* Update action.yml
  • Loading branch information
heiskr authored May 30, 2023
1 parent cb997c9 commit c71686c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
fetch-depth: 0 # Let's get all the branches
- name: Update to step 1
uses: skills/action-update-step@v1
uses: skills/action-update-step@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: 0
Expand Down
38 changes: 15 additions & 23 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ runs:
using: composite
steps:
- shell: bash
env:
GITHUB_TOKEN: ${{ inputs.token }}
FROM_STEP: ${{ inputs.from_step }}
TO_STEP: ${{ inputs.to_step }}
BRANCH_NAME: ${{ inputs.branch_name }}
BASE_BRANCH_NAME: ${{ inputs.base_branch_name }}
run: |
echo "Check that all required env variables are set"
if [ -z "$TO_STEP" ]
Expand All @@ -39,7 +45,7 @@ runs:
fi
echo "Check that we are on FROM_STEP"
if [ "$(cat .github/script/STEP)" != $FROM_STEP ]
if [ "$(cat .github/steps/-step.txt)" != $FROM_STEP ]
then
echo "Current step is not $FROM_STEP"
exit 0
Expand All @@ -48,28 +54,20 @@ runs:
echo "Make sure we are on the base branch ($BASE_BRANCH_NAME)"
git checkout $BASE_BRANCH_NAME
echo "Remove 'open' from any <details> tags"
sed -i.tmp -r 's/<details id=([0-9X]+) open>/<details id=\1>/g' README.md
echo "Add 'open' to step TO_STEP"
sed -i.tmp -r "s/<details id=$TO_STEP>/<details id=$TO_STEP open>/g" README.md
echo "Update all HTML comments to hide everything"
sed -i.tmp -r 's/<!--step([0-9X]+)-->/<!--step\1/g' README.md
sed -i.tmp -r 's/<!--endstep([0-9X]+)-->/endstep\1-->/g' README.md
echo "Update the step to TO_STEP"
NEXT_STEP=$(cat .github/steps/$TO_STEP-*.md)
HEADER=$(awk '/<header>/,/<\/header>/' README.md)
FOOTER=$(awk '/<footer>/,/<\/footer>/' README.md)
echo -e "$HEADER\n\n$NEXT_STEP\n\n$FOOTER" > README.md
echo "Show the current TO_STEP"
sed -i.tmp -r "s/<\!--step$TO_STEP/<\!--step$TO_STEP-->/g" README.md
sed -i.tmp -r "s/endstep$TO_STEP-->/<\!--endstep$TO_STEP-->/g" README.md
echo "Update the STEP file to TO_STEP"
echo "$TO_STEP" > .github/script/STEP
echo "Update step file to TO_STEP"
echo "$TO_STEP" > .github/steps/-step.txt
echo "Commit the files, and push to base branch"
git config user.name github-actions
git config user.email [email protected]
git add README.md
git add .github/script/STEP
git add .github/steps/-step.txt
git commit --message="Update to $TO_STEP in STEP and README.md"
git push
Expand All @@ -82,9 +80,3 @@ runs:
else
echo "Branch $BRANCH_NAME does not exist"
fi
env:
GITHUB_TOKEN: ${{ inputs.token }}
FROM_STEP: ${{ inputs.from_step }}
TO_STEP: ${{ inputs.to_step }}
BRANCH_NAME: ${{ inputs.branch_name }}
BASE_BRANCH_NAME: ${{ inputs.base_branch_name }}

0 comments on commit c71686c

Please sign in to comment.