alice-sites-pull-action/action.yml

74 lines
2.2 KiB
YAML
Raw Normal View History

2024-11-24 08:20:44 -03:00
name: "Alice Sites pull"
2024-11-24 15:13:39 -03:00
description: "Pulls and builds jekyll sites"
2024-11-24 08:20:44 -03:00
author: "Carneiro"
inputs:
2024-11-24 15:13:39 -03:00
src_dir:
2024-11-24 12:03:17 -03:00
description: "Source directory"
default: "/var/www/src/alice_sites"
2024-11-24 15:13:39 -03:00
dirname:
description: "Site directory (inside src_dir) name"
default: ${{ github.event.repository.name }}
2024-12-05 20:28:12 -03:00
output_dirname:
description: "Site destination directory name"
default: ${{ github.event.repository.name }}
2024-11-24 15:13:39 -03:00
dest_dir:
2024-11-24 12:03:17 -03:00
description: "Destination directory"
default: "/var/www/html/alice_sites"
2024-11-24 15:13:39 -03:00
jekyll_args:
2024-11-24 12:03:17 -03:00
description: "Args to pass to jekyll build"
default: "--trace --incremental"
2024-11-24 15:13:39 -03:00
skip_build:
2024-11-24 08:20:44 -03:00
description: "Wheather or not the sites skips building"
default: "false"
host:
description: "SSH host address."
default: "${{ secrets.SSH_HOST }}"
port:
description: "SSH port number."
default: ${{ secrets.SSH_PORT }}
username:
description: "SSH username."
default: "${{ secrets.SSH_USERNAME }}"
key:
description: "SSH private key"
default: ${{ secrets.SSH_PRIV_KEY }}
runs:
using: 'composite'
steps:
- uses: appleboy/ssh-action@v1.2.0
env:
2024-12-05 20:28:12 -03:00
ORIG_DIRNAME: ${{ github.event.repository.name }}
2024-11-24 15:13:39 -03:00
SITE_DIRNAME: ${{ inputs.dirname }}
2024-12-05 20:28:12 -03:00
OUTPUT_DIRNAME: ${{ inputs.output_dirname }}
2024-11-24 08:20:44 -03:00
REPO_NAME: ${{ gitea.repository }}
2024-11-24 15:13:39 -03:00
SKIP_BUILD: ${{ inputs.skip_build }}
SOURCE_DIR: ${{ inputs.src_dir }}
DEST_DIR: ${{ inputs.dest_dir }}
JEKYLL_ARGS: ${{ inputs.jekyll_args }}
2024-11-24 08:20:44 -03:00
with:
host: ${{ inputs.host }}
username: ${{ inputs.username }}
key: ${{ inputs.key }}
port: ${{ inputs.port }}
2024-11-24 12:03:17 -03:00
envs: SITE_DIRNAME, REPO_NAME, SKIP_BUILD, SOURCE_DIR, DEST_DIR, JEKYLL_ARGS
2024-11-24 08:20:44 -03:00
script: |
2024-12-05 20:28:12 -03:00
[ "$OUTPUT_DIRNAME" = "$ORIG_DIRNAME" ] && OUTPUT_DIRNAME=$SITE_DIRNAME
2024-11-24 12:03:17 -03:00
cd $SOURCE_DIR
2024-11-24 08:20:44 -03:00
2024-11-24 12:03:17 -03:00
# If site is not there yet, clone it
[ -d "${SOURCE_DIR}/${SITE_DIRNAME}" ] ||
git clone https://git.alice.ufsj.edu.br/$REPO_NAME
# Update
cd "${SOURCE_DIR}/${SITE_DIRNAME}"
git pull
# Build
2024-11-24 08:20:44 -03:00
[ $SKIP_BUILD != false ] && exit 0
2024-11-24 12:03:17 -03:00
bundle install
2024-12-05 20:28:12 -03:00
bundle exec jekyll build $JEKYLL_ARGS --destination=$DEST_DIR/$OUTPUT_DIRNAME