app_catalog_upd.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. name: Update Flipper Application Catalog
  2. on:
  3. push:
  4. branches:
  5. - main
  6. paths:
  7. - 'application.fam'
  8. jobs:
  9. update-catalog:
  10. runs-on: ubuntu-latest
  11. env:
  12. BRANCH_PREFIX: zacharyweiss/
  13. APP_NAME: magspoof
  14. APP_FOLDER: GPIO
  15. CATALOG_REPO: zacharyweiss/flipper-application-catalog
  16. CATALOG_UPSTREAM: flipperdevices/flipper-application-catalog
  17. CATALOG_FOLDER: flipper-application-catalog
  18. steps:
  19. - uses: actions/checkout@v4
  20. with:
  21. fetch-depth: 0
  22. path: ${{ env.APP_NAME }}
  23. - name: Get fap_version
  24. id: fap_version
  25. run: |
  26. cd $APP_NAME
  27. fap_version_raw=$(grep -oP '(?<=fap_version=\()\d+, \d+(?=\))' application.fam)
  28. v_major=$(echo $fap_version_raw | cut -d "," -f 1 | xargs)
  29. v_minor=$(echo $fap_version_raw | cut -d "," -f 2 | xargs)
  30. echo "v_major=$v_major" >> "$GITHUB_ENV"
  31. echo "v_minor=$v_minor" >> "$GITHUB_ENV"
  32. echo "branch_name=${BRANCH_PREFIX}${APP_NAME}_${v_major}.${v_minor}" >> "$GITHUB_ENV"
  33. - name: Checkout App Catalog
  34. uses: actions/checkout@v4
  35. with:
  36. repository: ${{ env.CATALOG_REPO }}
  37. path: ${{ env.CATALOG_FOLDER }}
  38. token: ${{ secrets.CATALOG_UPDATE_TOKEN }}
  39. - name: Create Branch & Fetch Upstream
  40. run: |
  41. cd $CATALOG_FOLDER
  42. git checkout -b "$branch_name"
  43. git remote add upstream "https://x-access-token:${{ secrets.CATALOG_UPDATE_TOKEN }}@github.com/$CATALOG_UPSTREAM.git"
  44. git fetch upstream main
  45. git remote -v
  46. git rebase --autosquash --autostash "upstream/main"
  47. # git remote set-url origin "https://x-access-token:${{ secrets.CATALOG_UPDATE_TOKEN }}@github.com/$CATALOG_REPO.git"
  48. - name: Update manifest.yml
  49. run: |
  50. manifest_path=applications/$APP_FOLDER/$APP_NAME/manifest.yml
  51. echo "manifest_path=$manifest_path" > "$GITHUB_ENV"
  52. sed -i 's/commit_sha: .*/commit_sha: ${{ github.sha }}/' $CATALOG_FOLDER/$manifest_path
  53. - name: Commit
  54. run: |
  55. cd $CATALOG_FOLDER
  56. git config user.name "$GITHUB_ACTOR"
  57. git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
  58. git add .
  59. git commit -m "Update ${APP_NAME} manifest for v${v_major}.${v_minor} @ ${{ github.sha }}"
  60. # git push --force -u origin HEAD
  61. - name: Push
  62. uses: ad-m/github-push-action@master
  63. with:
  64. github_token: ${{ secrets.CATALOG_UPDATE_TOKEN }}
  65. directory: ${{ env.CATALOG_FOLDER }}
  66. branch: ${{ env.branch_name }}
  67. repository: ${{ env.CATALOG_REPO }}
  68. force: true