Update Repository #16
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: Update Repository | |
# IMPORTANT: Only run on main/master branch. | |
on: | |
workflow_call: | |
secrets: | |
CODELESSLY_PROJECT_CONFIG: | |
required: true | |
CODELESSLY_APP_ACCESS_TOKEN: | |
required: true | |
workflow_dispatch: | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
# permissions: | |
# # Give the default GITHUB_TOKEN write permission to commit and push the | |
# # added or changed files to the repository. | |
# contents: write | |
# actions: write | |
steps: | |
- name: Checkout main repo | |
uses: actions/checkout@v4 | |
with: | |
path: main_repo | |
token: ${{ secrets.CODELESSLY_APP_ACCESS_TOKEN }} | |
- name: Install Dart | |
uses: dart-lang/setup-dart@v1 | |
- name: Dart SDK Version | |
run: dart --version | |
- name: Prepare Codelessly Script Runner | |
run: | | |
rm -rf codelessly_script_runner | |
git clone https://github.com/Codelessly/codelessly_script_runner.git --single-branch | |
cd codelessly_script_runner | |
dart pub get | |
- name: Clean main repo | |
run: dart codelessly_script_runner/bin/git_cleaner.dart main_repo | |
- name: Clone Latest Template | |
run: | | |
rm -rf codelessly_starter_brick | |
git clone https://github.com/Codelessly/codelessly_starter_brick.git --single-branch | |
- name: Move template to main repo | |
run: | | |
shopt -s dotglob | |
mv codelessly_starter_brick/__brick__/* main_repo | |
shopt -u dotglob | |
- name: Run script | |
run: dart codelessly_script_runner/bin/main.dart main_repo ${{ secrets.CODELESSLY_PROJECT_CONFIG }} | |
- name: Clean up before commit | |
run: | | |
rm -rf codelessly_script_runner | |
rm -rf codelessly_starter_brick | |
# IMPORTANT: Only works on Unix and needs bash | |
- name: Git Auto Commit | |
uses: stefanzweifel/git-auto-commit-action@v5.0.0 | |
with: | |
commit_message: "Update to latest template" | |
commit_options: '--no-verify --signoff' | |
# file_pattern: main_repo | |
repository: main_repo | |
commit_user_name: Codelessly Github Actions Bot | |
commit_user_email: codelessly@gmail.com | |
commit_author: Codelessly Actions Bot <codelessly@gmail.com> | |
token: ${{ secrets.CODELESSLY_APP_ACCESS_TOKEN }} | |
# - name: Commit and push changes | |
# run: | | |
# cd codelessly_starter_brick/__brick__ | |
# git init | |
# git checkout -b main | |
# git remote add origin https://github.repository_owner:${{ secrets.CODELESSLY_APP_ACCESS_TOKEN }}@github.com/${{ github.repository }}.git | |
# git config user.name Codelessly | |
# git config user.email codelessly@gmail.com | |
# git add . | |
# git commit -m "Update to latest template" | |
# git push --force origin ${{ github.ref_name }} | |
- name: Finish | |
run: echo "Finished" |