Run gulp tasks #159
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
name: Run gulp tasks | |
# Controls when the action will run | |
on: | |
workflow_dispatch: | |
push: | |
# On which branches | |
branches: | |
- dev | |
- prod | |
# On release | |
release: | |
types: [published] | |
# On PR | |
pull_request: | |
types: | |
- closed | |
branches: | |
- prod | |
# Variables | |
env: | |
dest_path: '/public_html/wp-content/themes/uncode-child' | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# Job name | |
build: | |
# Runner name | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
# with: | |
# ref: ${{ (github.event.release.target_commitish || github.ref_name) }} | |
# with: | |
# fetch-depth: 0 | |
# ref: ${{ github.event.pull_request.head.ref }} | |
# Sets up node | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
# Build | |
- name: Build | |
run: | | |
npm ci | |
gulp build | |
# Commit | |
- name: Commit files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "github-actions" | |
git status | |
git add --force build/* | |
git status | |
git commit --allow-empty -m "update gulp output files" | |
shell: bash | |
# Push | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
branch: ${{ (github.base_ref || github.ref) }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# Job name | |
rclone-dev: | |
# Run after build | |
needs: build | |
# Runner name | |
runs-on: ubuntu-latest | |
if: ${{ (github.event.release.target_commitish || github.ref_name) == 'dev' }} | |
steps: | |
# Checkout to the branch to use the last (build) commit | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ (github.event.release.target_commitish || github.ref_name) }} | |
# rclone | |
- name: Copy files on dev | |
uses: wei/rclone@v1 | |
env: | |
RCLONE_CONFIG_HDX_TYPE: ${{ secrets.RCLONE_CONFIG_HDX_TYPE }} | |
RCLONE_CONFIG_HDX_HOST: ${{ secrets.RCLONE_CONFIG_HDX_HOST }} | |
RCLONE_CONFIG_HDX_USER: ${{ secrets.RCLONE_CONFIG_HDX_USER_DEV }} | |
RCLONE_CONFIG_HDX_PASS: ${{ secrets.RCLONE_CONFIG_HDX_PASS_DEV }} | |
with: | |
args: copy build HDX:${{ env.dest_path }} | |
# Job name | |
rclone-prod: | |
# Run after build | |
needs: build | |
# Runner name | |
runs-on: ubuntu-latest | |
if: ${{ (github.event.release.target_commitish || github.ref_name) == 'prod' }} | |
steps: | |
# Checkout to the branch to use the last (build) commit | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ (github.event.release.target_commitish || github.ref_name) }} | |
# rclone | |
- name: Copy files on prod | |
uses: wei/rclone@v1 | |
env: | |
RCLONE_CONFIG_HDX_TYPE: ${{ secrets.RCLONE_CONFIG_HDX_TYPE }} | |
RCLONE_CONFIG_HDX_HOST: ${{ secrets.RCLONE_CONFIG_HDX_HOST }} | |
RCLONE_CONFIG_HDX_USER: ${{ secrets.RCLONE_CONFIG_HDX_USER_PROD }} | |
RCLONE_CONFIG_HDX_PASS: ${{ secrets.RCLONE_CONFIG_HDX_PASS_PROD }} | |
with: | |
args: copy build HDX:${{ env.dest_path }} |