Skip to content

Post for 2024-08-08 #1134

Post for 2024-08-08

Post for 2024-08-08 #1134

Workflow file for this run

name: Ruby
on:
push:
branches: [ deploy-aerobatic ]
pull_request:
branches: [ deploy-aerobatic ]
jobs:
build-main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Get date and time
id: get-datetime
run: |
# echo "::set-output name=datetime::$(/bin/date -u "+%Y%m%d%H%M")"
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
shell: bash
- name: Setup build cache
uses: actions/cache@v4
with:
key: cachedata-${{ steps.get-datetime.outputs.datetime }}
path: |
_site
_amp
_data/exif
.jekyll-cache
.sass-cache
restore-keys: |
cachedata-
- name: Sync metadata
env:
AWS_EC2_METADATA_DISABLED: true
AWS_ACCESS_KEY_ID: ${{ secrets.YC_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.YC_SECRET_ACCESS_KEY }}
run: aws --endpoint-url=https://storage.yandexcloud.net s3 sync s3://meta-dxfoto-ru _data --quiet --exclude "logs/*"
- name: Build main site
run: bundle exec jekyll build -I
- name: Sync main site
run: |
aws --endpoint-url=https://storage.yandexcloud.net s3 sync _site s3://www.dxfoto.ru --quiet
aws --endpoint-url=https://storage.yandexcloud.net s3api put-bucket-website --bucket img.dxfoto.ru --website-configuration file://today.json
env:
AWS_EC2_METADATA_DISABLED: true
AWS_ACCESS_KEY_ID: ${{ secrets.YC_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.YC_SECRET_ACCESS_KEY }}
build-amp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Get date and time
id: get-datetime
run: |
# echo "::set-output name=datetime::$(/bin/date -u "+%Y%m%d%H%M")"
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
shell: bash
- name: Setup build cache
uses: actions/cache@v3
with:
key: cachedata-${{ steps.get-datetime.outputs.datetime }}
path: |
_site
_amp
_data/exif
.jekyll-cache
.sass-cache
restore-keys: |
cachedata-
- name: Sync metadata
env:
AWS_EC2_METADATA_DISABLED: true
AWS_ACCESS_KEY_ID: ${{ secrets.YC_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.YC_SECRET_ACCESS_KEY }}
run: aws --endpoint-url=https://storage.yandexcloud.net s3 sync s3://meta-dxfoto-ru _data --quiet --exclude "logs/*"
- name: Build AMP site
env:
AMP: yes
run: |
AMP=yes bundle exec jekyll build -I --config _config-amp.yml
mv -f _amp/index-amp.html _amp/index.html
mv -f _amp/error-amp.html _amp/error.html
mv -f _amp/robots-amp.txt _amp/robots.txt
- name: Sync AMP site
run: aws --endpoint-url=https://storage.yandexcloud.net s3 sync _amp s3://amp.dxfoto.ru --quiet
env:
AWS_EC2_METADATA_DISABLED: true
AWS_ACCESS_KEY_ID: ${{ secrets.YC_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.YC_SECRET_ACCESS_KEY }}
finalize:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: ["build-main", "build-amp"]
steps:
- name: Purge CF cache
env:
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
CF_AUTH_EMAIL: ${{ secrets.CF_AUTH_EMAIL }}
CF_API_KEY: ${{ secrets.CF_API_KEY }}
run: |
curl -vvv -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/purge_cache" -H "Authorization: Bearer $CF_API_KEY" -H "Content-Type: application/json" --data '{"files": ["https://www.dxfoto.ru/", "https://amp.dxfoto.ru/", "https://www.dxfoto.ru/feed.xml", "https://img.dxfoto.ru/today.jpg"]}'
- name: Notify when success
uses: zulip/github-actions-zulip/send-message@v1
if: ${{ success() }}
with:
api-key: ${{ secrets.ZULIP_GHBOT_API_KEY }}
email: "kaop9VSKAwXiOePnRNOp7bMQ-bot@dxfoto-ru.zulipchat.com"
organization-url: "https://dxfoto-ru.zulipchat.com/"
to: "594647" # user_id
type: "private"
content: "Сайт собрался"
- name: Notify when failure
uses: zulip/github-actions-zulip/send-message@v1
if: ${{ failure() }}
with:
api-key: ${{ secrets.ZULIP_GHBOT_API_KEY }}
email: "kaop9VSKAwXiOePnRNOp7bMQ-bot@dxfoto-ru.zulipchat.com"
organization-url: "https://dxfoto-ru.zulipchat.com/"
to: "594647" # user_id
type: "private"
content: "Сайт не собрался"