Skip to content

Deploy to Components Library #1250

Deploy to Components Library

Deploy to Components Library #1250

name: Deploy to Components Library
env:
# Username/email used to commit to the Core Components Library
PROJECT_DIR: commerce-cif-components
# Components Library
TARGET_REPO: ${{ secrets.LIBRARY_REPOSITORY }}
TARGET_BRANCH: ${{ secrets.LIBRARY_BRANCH_DEV }}
USER_EMAIL: ${{ secrets.LIBRARY_USER_EMAIL }}
USER_NAME: ${{ secrets.LIBRARY_USER_NAME }}
USER_PWD: ${{ secrets.LIBRARY_PASSWORD }}
# Only run on a push to this branch
on:
schedule:
- cron: '0 22 * * *'
workflow_dispatch:
jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2
- name: Print latest_commit
run: echo ${{ github.sha }}
- name: Check latest commit is less than a day
id: should_run
continue-on-error: true
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"
build:
needs: check_date
if: ${{ needs.check_date.outputs.should_run != 'false' }}
runs-on: ubuntu-latest
name: Deploy CIF Core Components Library
steps:
# Checkout this project into a sub folder
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2
with:
path: sub
# Cleanup sub project
- name: Clean project
run: |
git -C sub log --format="%an : %s" -n 1 > commit.txt
rm -rf sub/.git
rm -rf sub/.github
# Set global git configuration
- name: Set git config
run: |
git config --global credential.helper cache
git config --global user.email ${USER_EMAIL}
git config --global user.name ${USER_NAME}
# Checkout the main project
- name: Checkout main project
run:
git clone -b ${TARGET_BRANCH} https://${USER_EMAIL}:${USER_PWD}@${TARGET_REPO} main
# Move sub project
- name: Move project to main
run: |
rm -rf main/${PROJECT_DIR}
mv sub main/${PROJECT_DIR}
- name: Commit Changes
run: |
git -C main add ${PROJECT_DIR}
git -C main commit -F ../commit.txt
git -C main push