Skip to content

Update library zip and submodules #162

Update library zip and submodules

Update library zip and submodules #162

name: Update library zip and submodules
on:
push:
branches:
- master
schedule:
- cron: '0 1 * * 0'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
# check out the repo
- uses: actions/checkout@v2
with:
ref: master
submodules: false
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Restore or Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
# if requirements.txt hasn't changed, then it will be a "cache hit" and pip will be restored
# if requirements.txt HAS changed, it will be a "cache miss" and a new cache of pip will be created if the job completes successfully
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Set up Python
uses: actions/setup-python@v2
with:
# Semantic version range syntax or exact version of a Python version
python-version: '2.7'
- name: Install git-archive
run: pip install -U git-archive-all
- name: Install submodules
run: |
git config --global user.email "sdamiano@stroudcenter.org"
git config --global user.name "SRGDamia1"
git config --global push.default simple
git submodule init
git status
git submodule update --remote --recursive
git status
- name: Queue changes in submodules for commit
run: |
git add -A
git status
- name: Create submodule_status file
run: |
echo "::debug::Creating a new submodule status file.\n"
git submodule status --recursive > submodule_status.txt
git status
echo "::debug::Checking for changes in the submodule status file."
git diff HEAD -- submodule_status.txt
echo "::debug::Setting a new environment variable"
echo "submod_updated=$(git diff --name-only HEAD -- submodule_status.txt)" >> $GITHUB_ENV
echo "::debug::submodules updated = $submod_updated"
- name: Check env variable
run: echo submodules updated = $submod_updated
- name: Zip submodules
if: ${{ env.submod_updated }}
run: |
echo "::debug::Archiving Submodules."
git-archive-all --force-submodules libraries.zip
git status
- name: Remove git folders and files from zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Deleting extra files to decrease size of zip"
echo "::debug::Removing Git folders"
zip -d -q libraries "*/.gitattributes" "*/.gitignore" "*/.gitmodules" "*/.github/*" "*.sh" "*/Doxyfile" "*/.travis.yml"
- name: Remove pdfs from the zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Removing other pdfs"
zip -d -q libraries "*/doc/*.pdf"
- name: Remove TinyGSM extras from the zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Removing TinyGSM extras"
zip -d -q libraries "*/TinyGSM/extras/*"
- name: Remove YosemitechModbus extras from the zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Removing YosemitechModbus extras"
zip -d -q libraries "*/YosemitechModbus/doc/*"
- name: Remove SDFat extras from the zip
if: ${{ env.submod_updated }}
continue-on-error: true
run: |
echo "::debug::Removing SDFat extras"
zip -d -q libraries "*/SdFat/extras/*"
- name: Queue zip
if: ${{ env.submod_updated }}
run: |
echo "::debug::Queueing changes for commit"
git add -A;
echo "::debug::Git status"
git status
echo "::debug::Setting a new environment variable"
git diff --name-only HEAD -- libraries.zip
echo "is_changed=$(git diff --name-only HEAD -- libraries.zip)" >> $GITHUB_ENV
echo "::debug::zip changed = $is_changed"
- name: Check env variable
run: echo zip changed = $is_changed
- name: Commit changes to master
if: ${{ env.is_changed }}
run: |
git commit -m "Updated submodules and zip via Github Action (${{ github.workflow }} ${{ github.event_name }} ${{ github.run_number }} ) [ci skip]";
- name: Push changes to master
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.SARA_PUSH_TOKEN }}
branch: master
- name: Checkout platformio branch
run: |
echo "::debug::Stashing changes before switching branches"
git stash
echo "::debug::Checking out the platformio branch"
git checkout platformio
git status
echo "::debug::Checking out the library manifest from the master branch"
git checkout master -- library.json
git status
echo "::debug::Queueing changes to the manifest for commit"
git add library.json
git status
echo "::debug::Setting a new environment variable"
git diff --name-only HEAD -- library.json
echo "manifest_changed=$(git diff --name-only HEAD -- library.json)" >> $GITHUB_ENV
echo "::debug::manifest changed = $manifest_changed"
- name: Check env variable
run: echo manifest changed = $manifest_changed
- name: Commit changes to platformio branch
if: ${{ env.manifest_changed }}
run: git commit -m "Updated library.json via Github Action (${{ github.workflow }} ${{ github.event_name }} ${{ github.run_number }} ) [ci skip]";
- name: Push to platformio branch
if: ${{ env.manifest_changed }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.SARA_PUSH_TOKEN }}
branch: platformio