Centos Linux 错误 su: failed to execute /bin/bash: Resource temporarily unavailable 解决 #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate README | |
on: | |
workflow_dispatch: | |
issues: | |
types: [opened, edited] | |
issue_comment: | |
types: [created, edited] | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
if: github.repository_owner_id == github.event.issue.user.id || github.event_name == 'push' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Fetch Issues | |
run: | | |
curl -s -H "Authorization: token ${{ secrets.G_T }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
"https://api.github.com/repos/${{ github.repository }}/issues?state=all" > issues.json | |
- name: Process Issues | |
run: | | |
DIRNAME="post_issues" | |
mkdir -p "$DIRNAME" | |
jq -c '.[]' issues.json | while read -r issue; do | |
NUMBER=$(echo "$issue" | jq -r '.number') | |
TITLE=$(echo "$issue" | jq -r '.title') | |
FILENAME=$(echo "$issue" | jq -r '.title' | sed 's/[\\/:\ \"*?"<>|]/-/g; s/-\+/-/g') | |
CREATED_AT=$(echo "$issue" | jq -r '.created_at'|date '+%Y-%m-%d %H:%M:%S' -f -) | |
SORTDATE=$(date -d "$CREATED_AT" +%y%m%d) | |
HTML_URL=$(echo "$issue" | jq -r '.html_url') | |
BODY=$(echo "$issue" | jq -r '.body // ""') | |
FILE="${DIRNAME}/${NUMBER}_${FILENAME}.md" | |
echo "---" > "$FILE" | |
echo "title: \"$TITLE\"" >> "$FILE" | |
echo "date: $CREATED_AT" >> "$FILE" | |
echo "toc: yes" >> "$FILE" | |
echo "comment: true" >> "$FILE" | |
echo "---" >> "$FILE" | |
echo "" >> "$FILE" | |
echo "# $TITLE" >> "$FILE" | |
echo "$BODY" >> "$FILE" | |
COMMENTS_URL="https://api.github.com/repos/${{ github.repository }}/issues/$NUMBER/comments" | |
COMMENTS=$(curl -s -H "Authorization: token ${{ secrets.G_T }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
"$COMMENTS_URL") | |
mapfile -t COMMENT_ARRAY < <(echo "$COMMENTS" | jq -c '.[]') | |
for comment in "${COMMENT_ARRAY[@]}"; do | |
echo "comment: $comment" | |
AUTHOR_ASSOCIATION=$(echo "$comment" | jq -r '.author_association') | |
if [ "$AUTHOR_ASSOCIATION" == "OWNER" ]; then | |
COMMENT_BODY=$(echo "$comment" | jq -r '.body') | |
echo "" >> "$FILE" | |
echo "---" >> "$FILE" | |
echo "$COMMENT_BODY" >> "$FILE" | |
fi | |
done | |
echo "$SORTDATE <li> <a href=\"$HTML_URL\">$TITLE</a></li>" >> README.txt | |
done | |
rm -f issues.json | |
- name: Process Original Markdown source | |
run: | | |
SOURCE_DIR="post_source" | |
for file in ./${SOURCE_DIR}/*.md | |
do | |
[ -e "$file" ] || continue | |
TITLE="" | |
POSTDATE="" | |
DATE="" | |
COMMENT="" | |
POST=$(basename "$file" .md) | |
t_count=0 | |
while IFS= read -r line | |
do | |
if [[ "$line" =~ (^---$) ]] | |
then | |
t_count=$((t_count+1)) | |
fi | |
if [[ t_count -ge 2 ]]; then | |
break | |
fi | |
if [[ "$line" =~ itle:(.*$) ]] | |
then | |
TITLE=$(echo "$line" |sed -n 's/.itle: //p') | |
fi | |
if [[ "$line" =~ ate:(.*$) ]] | |
then | |
POSTDATE=$(echo "$line" |sed -n 's/.ate: //p') | |
fi | |
if [[ "$line" =~ odify:(.*$) ]] | |
then | |
POSTDATE=$(echo "$line" |sed -n 's/.odify: //p') | |
fi | |
done < "$file" | |
SORTDATE=$(date -d "$POSTDATE" +%y%m%d) | |
DATE=$(echo -n $POSTDATE |cut -d ' ' -f 1) | |
echo "$SORTDATE" '<li> <a href="'"$SOURCE_DIR/$POST.md"'">'"$TITLE"'</a></li>' >> README.txt | |
done | |
- name: Generate README.md | |
env: | |
BLOG_TITLE: ${{ vars.BLOG_TITLE }} | |
BASE_URL: ${{ vars.BASE_URL }} | |
run: | | |
list_to_readme_md() { | |
input_file=$1 | |
output_file=$2 | |
rm -f "$output_file" | |
temp_file=$(mktemp) | |
BLOG_TITLE="${BLOG_TITLE:-"BLOG"}" | |
BASE_URL="${BASE_URL:-""}" | |
if [[ -n "$BLOG_TITLE" ]]; then | |
if [[ -n "$BASE_URL" ]]; then | |
echo "## [$BLOG_TITLE]($BASE_URL)" >> $output_file | |
else | |
echo "## $BLOG_TITLE" >> $output_file | |
fi | |
fi | |
sort -r -k1,1 "$input_file" > "$temp_file" | |
prev_year="" | |
months=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) | |
while read -r line; do | |
date=$(echo "$line" | awk '{print $1}') | |
month_index=$((10#${date:2:2} - 1)) | |
day=${date:4:2} | |
month=${months[$month_index]} | |
content=$(echo "$line" | sed 's/^[0-9]\{6\} //') | |
year="20${date:0:2}" | |
if [[ "$year" != "$prev_year" ]]; then | |
echo "## $year" >> "$output_file" | |
prev_year="$year" | |
fi | |
href=$(echo "$line" | grep -oP '(?<=href=")[^"]+') | |
title=$(echo "$line" | grep -oP '(?<=>)[^<]*'| tr -d '\n') | |
echo "- [$title]($href) on $month $day" >> "$output_file" | |
done < "$temp_file" | |
rm "$temp_file" | |
} | |
list_to_readme_md README.txt README.md | |
- name: Commit and Push Changes | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git add README.md post_issues/*.md | |
git commit -a -m "update readme by the github action." || echo "No changes to commit" | |
git push || echo "Nothing to push" |