Skip to content

Commit

Permalink
ci(update-readme): fix sed syntax issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shawly committed Jul 24, 2024
1 parent caa2279 commit f68e2a4
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,28 +257,32 @@ jobs:
uses: actions/checkout@v4
with:
ref: main

- name: Prepare variables
- name: Set start and end comment
if: needs.build.outputs.publish == 'true'
id: prep
id: comment
run: |
README_TAGS=$(jq -r '"- " + (.[] | [.tags[] | "`" + . + "`"] | join(", "))' <<< '${{ needs.build-matrix.outputs.releases }}')
# Replace supported tags in README.md
# Define the start and end comments in the README.md file
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
start_comment='<!-- edge tags start -->'
end_comment='<!-- edge tags end -->'
echo 'start_comment=<!-- edge tags start -->' >> "$GITHUB_OUTPUT"
echo 'end_comment=<!-- edge tags end -->' >> "$GITHUB_OUTPUT"
else
start_comment='<!-- latest tags start -->'
end_comment='<!-- latest tags end -->'
echo 'start_comment=<!-- latest tags start -->' >> "$GITHUB_OUTPUT"
echo 'end_comment=<!-- latest tags end -->' >> "$GITHUB_OUTPUT"
fi
- name: Prepare variables
if: needs.build.outputs.publish == 'true'
id: prep
run: |
README_TAGS=$(jq -r '"- " + (.[] | [.tags[] | "`" + . + "`"] | join(", "))' <<< '${{ needs.build-matrix.outputs.releases }}')
# Cleanout space between start and end comment
sed -i '/'${start_comment}'/,/'${end_comment}'/ { //!d }' README.md
sed -i '/${{ steps.comment.outputs.start_comment }}/,/${{ steps.comment.outputs.end_comment }}/ { //!d }' README.md
# Replace the tags
sed -i "\\~${start_comment}~,\\~${end_comment}~ { \\|${start_comment}|r /dev/stdin
sed -i "\\~${{ steps.comment.outputs.start_comment }}~,\\~${{ steps.comment.outputs.end_comment }}~ { \\|${{ steps.comment.outputs.start_comment }}|r /dev/stdin
}" README.md <<< "$README_TAGS"
- name: Check for modified files
Expand Down

0 comments on commit f68e2a4

Please sign in to comment.