-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9facf75
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Format | ||
|
||
on: | ||
push: | ||
schedule: | ||
- cron: '*/15 * * * *' | ||
|
||
env: | ||
UNSPLASH_ACCESS_KEY: ${{ secrets.UNSPLASH_ACCESS_KEY }} | ||
|
||
jobs: | ||
format-code: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: 'Update _redirects' | ||
run: | | ||
chmod +x ./refresher.sh | ||
./refresher.sh | ||
- uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_author: Author <[email protected]> | ||
commit_options: '--amend --no-edit' | ||
push_options: '--force' | ||
skip_fetch: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/internetztube/raw https://images.unsplash.com/photo-1589186050672-a42c96e47b6b?ixid=M3w2NjExODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MjgwNjMxNjB8&ixlib=rb-4.0.3 302 | ||
/internetztube/full https://images.unsplash.com/photo-1589186050672-a42c96e47b6b?crop=entropy&cs=srgb&fm=jpg&ixid=M3w2NjExODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MjgwNjMxNjB8&ixlib=rb-4.0.3&q=85 302 | ||
/internetztube/regular https://images.unsplash.com/photo-1589186050672-a42c96e47b6b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w2NjExODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MjgwNjMxNjB8&ixlib=rb-4.0.3&q=80&w=1080 302 | ||
/internetztube/small https://images.unsplash.com/photo-1589186050672-a42c96e47b6b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w2NjExODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MjgwNjMxNjB8&ixlib=rb-4.0.3&q=80&w=400 302 | ||
/internetztube/thumb https://images.unsplash.com/photo-1589186050672-a42c96e47b6b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w2NjExODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MjgwNjMxNjB8&ixlib=rb-4.0.3&q=80&w=200 302 | ||
/internetztube/small_s3 https://s3.us-west-2.amazonaws.com/images.unsplash.com/small/photo-1589186050672-a42c96e47b6b 302 | ||
/* https://github.com/internetztube/unsplash-random 301 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Get your Unsplash Access Key it from here: | ||
# https://unsplash.com/oauth/applications/new | ||
# UNSPLASH_ACCESS_KEY="" | ||
|
||
# Multi line string of Unsplash usernames. | ||
# The Unsplash Demo API has a Rate Limit of 50 requests per hour. Therefore, you can put up to 50 usernames in here. | ||
# Feel free to add your username! | ||
UNSPLASH_USERNAMES=" | ||
internetztube | ||
" | ||
|
||
FALLBACK_TARGET="https://github.com/internetztube/unsplash-random" | ||
FILENAME="_redirects" | ||
|
||
rm $FILENAME | ||
touch $FILENAME | ||
|
||
echo "$UNSPLASH_USERNAMES" | while read -r username; do | ||
username=$(echo "$username" | xargs) | ||
|
||
if [ -n "$username" ]; then | ||
response=$(curl -s "https://api.unsplash.com/photos/random?username=${username}&client_id=${UNSPLASH_ACCESS_KEY}") | ||
response=$(echo $response | tr -d '\000-\037') | ||
|
||
for url in $(echo $response | jq -r '.urls | to_entries[] | "\(.key)=\(.value)"'); do | ||
echo "/$username/${url%%=*} ${url#*=} 302" >> $FILENAME | ||
done | ||
|
||
fi | ||
done | ||
|
||
if ! [ -z "$FALLBACK_TARGET" ]; then | ||
echo "/* ${FALLBACK_TARGET} 301" >> $FILENAME | ||
fi |