Skip to content

백준 2252번 줄 세우기 #178

백준 2252번 줄 세우기

백준 2252번 줄 세우기 #178

name: Creating bitly link for main.py
on:
push:
branches: [ master ]
jobs:
job1:
runs-on: ubuntu-latest
steps:
- name: get repo
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: get path of main.py
shell: bash
run: |
git -c core.quotepath=false diff --name-only HEAD~1 HEAD | grep '/main\.py'
echo "path_of_main_py=$(git -c core.quotepath=false diff --name-only HEAD~1 HEAD | grep '/main\.py')" >> $GITHUB_ENV
echo $path_of_main_py
- name: Check main.py exists
shell: bash
run: |
path_of_main_py=$(echo '${{ env.path_of_main_py }}' | sed -e 's/([^)]*)//g')
echo $path_of_main_py
if [ -z $path_of_main_py ]; then
echo "No main.py exists"
exit 1
fi
- name: Get first line of last commit message
shell: bash
run: |
echo "one_line=$(git log --oneline -n 1 --format=%B | head -n 1)" >> $GITHUB_ENV
- name: Decorate path_of_main_py
shell: bash
env:
BITLY_PAT: ${{ secrets.BITLY_PAT }}
run: |
echo "path_of_main_py=https://github.com/skysign/WSAPT/blob/master/${{ env.path_of_main_py }}" >> $GITHUB_ENV
echo "${{ env.path_of_main_py }}"
- name: Create bit.ly short url
env:
BITLY_PAT: ${{ secrets.BITLY_PAT }}
shell: bash
run: |
curl \
-H "Authorization: Bearer ${{ env.BITLY_PAT }}" \
-H "Content-Type: application/json" \
-X POST \
-d '{"long_url": "${{ env.path_of_main_py }}", "title": "${{ env.one_line }}"}' \
https://api-ssl.bitly.com/v4/bitlinks