-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (119 loc) · 4.34 KB
/
workflow.yml
File metadata and controls
132 lines (119 loc) · 4.34 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: directory-listing
on: [push]
jobs:
pages-directory-listing:
runs-on: ubuntu-24.04
name: Directory Listings Index
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: main #checkout different branch
- name: Generate Directory Listings
uses: objectstack/github-pages-object-listing@v4.1.0
with:
FOLDER: data #directory to generate index
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'data' # upload generated folder
deploy:
needs: pages-directory-listing
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
notification-events:
name: "Toot & Tweet objects"
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Toot added or changed files
run: |
toot () {
echo "$1" "$2"
if [ -z "$2" ];then
curl -F "api_base_url=https://toot.io" \
-F "access_token=${{ secrets.OBJSTACK_TOOT_ACCESS_TOKEN }}"\
-F "message=$1" \
https://kubectl.linuxmail.in/mastodon/toot
else
curl -F "api_base_url=https://toot.io" \
-F "access_token=${{ secrets.OBJSTACK_TOOT_ACCESS_TOKEN }}"\
-F "message=$1" \
-F image=@"$2" \
https://kubectl.linuxmail.in/mastodon/toot
fi
}
tweet () {
echo "$1" "$2"
if [ -z "$2" ];then
curl -X "POST" "https://graph.edc0.com/twitter/tweet" \
-F "consumer_key=${{ secrets.OBJSTACK_TWEET_API_KEY }}" \
-F "consumer_secret=${{ secrets.OBJSTACK_TWEET_API_SECRET }}" \
-F "access_token_key=${{ secrets.OBJSTACK_TWEET_ACCESS_TOKEN }}" \
-F "access_token_secret=${{ secrets.OBJSTACK_TWEET_ACCESS_TOKEN_SECRET }}" \
-F "message=$1"
else
curl -X "POST" "https://graph.edc0.com/twitter/tweet" \
-F "consumer_key=${{ secrets.OBJSTACK_TWEET_API_KEY }}" \
-F "consumer_secret=${{ secrets.OBJSTACK_TWEET_API_SECRET }}" \
-F "access_token_key=${{ secrets.OBJSTACK_TWEET_ACCESS_TOKEN }}" \
-F "access_token_secret=${{ secrets.OBJSTACK_TWEET_ACCESS_TOKEN_SECRET }}" \
-F "message=$1" \
-F image=@"$2"
fi
}
files=($(git --no-pager show --oneline --name-only --pretty='' HEAD))
if (( ${#files[@]} <= 4 ));
then
IFS=""
for f in ${files[@]};
do
file_part=$(echo "$f" | awk -F "data/" '{print $NF}')
url="https://cdn.edc0.com/$file_part"
case "$f" in
*data/maverickmac/images* )
#tweet "${f##*/} $url" "$f"
tweet "${f##*/} $url" "$f"
;;
*data/maverickmac* )
#toot "${f##*/} $url"
tweet "${f##*/} $url"
;;
*data/images* )
#toot "${f##*/} $url" "$f"
tweet "${f##*/} $url" "$f"
;;
*data/* )
#toot "${f##*/} $url"
tweet "${f##*/} $url"
;;
esac
sleep 2
done
else
echo "No modified files";
fi
- name: Backup with rclone
run: |
cat << EOF > ./rclone.conf
${{ secrets.OBJSTACK_RCLONE_CONF }}
EOF
sudo apt install -y rclone
rclone --config rclone.conf copy -v --check-first --size-only --max-size 1G \
--max-age 30d -u --no-update-modtime \
data/ Gdrive-IILM:/Github/objectstack.github.io/data/