-
Notifications
You must be signed in to change notification settings - Fork 1
46 lines (45 loc) · 1.58 KB
/
main_py_to_bitly.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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: |
echo "path_of_main_py=$(git -c core.quotepath=false diff --name-only HEAD~1 HEAD | grep '/main\.py')" >> $GITHUB_ENV
- name: Check main.py exists
shell: bash
run: |
if [ -z ${{ env.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