Skip to content

Updated remote

Updated remote #91

Workflow file for this run

name: Pull Files from Another Repository on Push
env:
SOURCE_REPO: lwcorp/lwserver
AUTOMATIC_MONITOR: true
FILES: "*.au3 LICENSE" # separate multiple entries with ,
FILES_NEW: "*.au3 LICENSE*" # separate multiple entries with ,
EXTRA: mv LICENSE LICENSE_LWServer # do an extra command like renaming
USERNAME: ${{ github.actor }}
ADDRESS_SUFFIX: users.noreply.github.com
TOKEN_NAME: ACCESS_TOKEN # name of token defined in the target repo's settings, needed for private repos
# SOURCE_BRANCH: source_alternate_branch # uncomment to takes files from a non default source branch
# TARGET_BRANCH: target_alternate_branch # uncomment to monitor a non default target branch
# TARGET_PATH: target_alternate_path # uncomment to monitor a non default target branch
THE_SERVER: ${{ github.server_url }}
PATH_SOURCE_CHECKOUT: temp_folder
THE_SECRET: ${{ secrets.TOKEN_NAME || 'default_value' }}
on: # Remove # below for non default branches
workflow_dispatch:
push:
# branches:
# - ${{ env.TARGET_BRANCH }}
# paths:
# - ${{ env.TARGET_PATH }}
jobs:
pull-file:
runs-on: ubuntu-latest
steps:
- name: Check whether to automatically monitor
if: ${{ github.event_name != 'workflow_dispatch' && env.AUTOMATIC_MONITOR == false }}
run: |
echo "Set not to run automatically. Exiting."
echo "exiting1=true" >> $GITHUB_ENV
- name: Checkout
if: env.exiting1 != 'true'
uses: actions/checkout@v3
- name: Checkout source with token and branch
if: env.exiting1 != 'true' && env.THE_SECRET != 'default_value' && env.SOURCE_BRANCH
uses: actions/checkout@v3
with:
repository: ${{ env.SOURCE_REPO }}
ref: ${{ env.SOURCE_BRANCH }}
token: ${{ secrets[env.TOKEN_NAME] }}
path: ${{ env.PATH_SOURCE_CHECKOUT }}
- name: Checkout source with token but without branch
if: env.exiting1 != 'true' && env.THE_SECRET != 'default_value' && !env.SOURCE_BRANCH
uses: actions/checkout@v3
with:
repository: ${{ env.SOURCE_REPO }}
token: ${{ secrets[env.TOKEN_NAME] }}
path: ${{ env.PATH_SOURCE_CHECKOUT }}
- name: Checkout source without token but with branch
if: env.exiting1 != 'true' && env.THE_SECRET == 'default_value' && env.SOURCE_BRANCH
uses: actions/checkout@v3
with:
repository: ${{ env.SOURCE_REPO }}
ref: ${{ env.SOURCE_BRANCH }}
path: ${{ env.PATH_SOURCE_CHECKOUT }}
- name: Checkout source without token and without branch
if: env.exiting1 != 'true' && env.THE_SECRET == 'default_value' && !env.SOURCE_BRANCH
uses: actions/checkout@v3
with:
repository: ${{ env.SOURCE_REPO }}
path: ${{ env.PATH_SOURCE_CHECKOUT }}
- name: Update
if: env.exiting1 != 'true'
run: |
cd $PATH_SOURCE_CHECKOUT
$EXTRA
cp -u $FILES_NEW ../
cd ..
- name: Check for changes
if: env.exiting1 != 'true'
run: |
if git diff --quiet; then
echo "No changes detected. Exiting."
echo "exiting2=true" >> $GITHUB_ENV
fi
- name: Commit
if: env.exiting1 != 'true' && env.exiting2 != 'true'
run: |
git config user.name "$USERNAME"
git config user.email "$USERNAME@$ADDRESS_SUFFIX"
git add $FILES_NEW
git commit -m "Pulled files from $THE_SERVER/$SOURCE_REPO."
- name: Push
if: env.exiting1 != 'true' && env.exiting2 != 'true'
run: |
if [ -n "$TARGET_BRANCH" ]; then
git push origin $TARGET_BRANCH
else
git push
fi