diff options
| author | Ha Thach <[email protected]> | 2021-02-07 15:55:45 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-07 15:55:45 +0700 |
| commit | f49d47a0aa6781e8c4f86fbb7725c23f6549b14e (patch) | |
| tree | b552d3e42be48695387c4167d61f70ec51c4ff31 /.github/workflows | |
| parent | be1bd74b4b0c2392d3232c995a5d0604d7938d85 (diff) | |
Mirror sources only to hathach/tinyusb_src repo (#636)
Mirror sources only to hathach/tinyusb_src repo
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/trigger.yml | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/.github/workflows/trigger.yml b/.github/workflows/trigger.yml index a7ef1341d..40750a2f9 100644 --- a/.github/workflows/trigger.yml +++ b/.github/workflows/trigger.yml @@ -3,12 +3,56 @@ name: Trigger Repos on: push: branches: master - + release: + types: + - created + jobs: - trigger: + trigger-mynewt: + if: github.repository == 'hathach/tinyusb' runs-on: ubuntu-latest steps: - - name: mynewt-tinyusb-example + - name: Trigger mynewt-tinyusb-example shell: bash run: | - curl -X POST -H "Authorization: token ${{ secrets.GH_REPO_TOKEN }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" --data '{"event_type": "rebuild"}' https://api.github.com/repos/hathach/mynewt-tinyusb-example/dispatches + curl -X POST -H "Authorization: token ${{ secrets.API_TOKEN_GITHUB }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" --data '{"event_type": "rebuild"}' https://api.github.com/repos/hathach/mynewt-tinyusb-example/dispatches + + mirror-tinyusb-src: + if: github.repository == 'hathach/tinyusb' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Push to tinyusb_src + run: | + # clone tinyusb_src with PAT + git config --global user.email "[email protected]" + git config --global user.name "hathach" + git clone --depth 1 --single-branch --branch main "https://${{ secrets.API_TOKEN_GITHUB }}@github.com/hathach/tinyusb_src.git" tinyusb_src + + # Remove all files + rm -rf tinyusb_src/* + + # Copy src and other files + cp -r src tinyusb_src/ + cp LICENSE tinyusb_src/ + cd tinyusb_src + + # Commit if there is changes + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" + git push + fi + + - name: Create tinyusb_src Release + if: ${{ github.event_name == 'release' }} + run: | + # Push tag + cd tinyusb_src + git tag ${{ github.event.release.tag_name }} + git push origin ${{ github.event.release.tag_name }} + + # Send POST reqwuest to release https://docs.github.com/en/rest/reference/repos#create-a-release + curl -X POST -H "Authorization: token ${{ secrets.API_TOKEN_GITHUB }}" -H "Accept: application/vnd.github.v3+json" --data '{"tag_name": "${{ github.event.release.tag_name }}", "name": "${{ github.event.release.name }}", "body": "${{ github.event.release.body }}", "draft": ${{ github.event.release.draft }}, "prerelease": ${{ github.event.release.prerelease }}}' https://api.github.com/repos/hathach/tinyusb_src/releases |
