Skip to content

generate_juis

generate_juis #130

Workflow file for this run

name: generate_juis
on:
push:
branches: [ master ]
paths:
- '.github/workflows/generate_juis.yml'
- 'docs/juis/generate.sh'
schedule:
- cron: '30 16 * * 1-5'
workflow_dispatch:
jobs:
build:
container:
# image: ubuntu:20.04
# image: freetzng/generate
image: ghcr.io/freetz-ng/generate
runs-on: ubuntu-latest
if: github.repository == 'freetz-ng/freetz-ng'
steps:
- name: key
id: key
run: |
export KEY="${GITHUB_WORKFLOW%-*}"
echo "key=$KEY" >> $GITHUB_OUTPUT
echo "################################################################" && bash -c "echo KEY=$KEY"
# - name: update
# run: apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade
#
# - name: install
# run: |
# DEBIAN_FRONTEND=noninteractive apt-get -y install \
# git locales netcat curl bsdmainutils xxd libarchive-zip-perl
#
# - name: locale
# run: locale-gen en_US.utf8 && locale-gen de_DE.UTF-8 && update-locale
- name: clone
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
umask 0022
git config --global --add safe.directory $GITHUB_WORKSPACE
git clone https://github-actions:$GITHUB_TOKEN@${GITHUB_SERVER_URL##*/}/$GITHUB_REPOSITORY.git $GITHUB_WORKSPACE --branch $GITHUB_REF_NAME
- name: cache_load
uses: actions/cache/restore@v4
if: always()
with:
path: |
/tmp/.freetz-juis
key: ${{ github.workflow }}
- name: generate
run: |
export LANG=en_US.utf8
[ "${{ github.workflow }}" != "${{ steps.key.outputs.key }}" ] && c=5 || c=1
seq $c | while read x; do docs/juis/generate.sh; done
- name: commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git pull
git add .
git status
git config --local user.name github-actions
git config --local user.email github-actions@github.com
git diff --cached --quiet && exit 0 || git commit -m "juis: automatic update"
git config --local credential.helper '!x() { echo "password=$GITHUB_TOKEN"; };x'
git push origin $GITHUB_REF_NAME
- name: cache_clear
env:
ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
run: |
ASSETS="$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $ACTIONS_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/actions/caches")"
ASSID="$(echo "$ASSETS" | grep -B7 "\"key\": *\"${{ steps.key.outputs.key }}\"" | sed -rn 's/ *"id": *([^,]*),*/\1/p')"
curl -sL -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $ACTIONS_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/actions/caches/$ASSID" && echo "Deleted ASSID=$ASSID ..." || true
- name: cache_save
uses: actions/cache/save@v4
if: always()
with:
path: |
/tmp/.freetz-juis
key: ${{ steps.key.outputs.key }}