|
| 1 | +name: Notify Engine of RNN Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + release_tag: |
| 9 | + description: 'Release tag to use (e.g. 8.7.6)' |
| 10 | + required: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + notify-engine: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Determine release version |
| 22 | + id: version |
| 23 | + run: | |
| 24 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 25 | + echo "tag=${{ github.event.inputs.release_tag }}" >> $GITHUB_OUTPUT |
| 26 | + else |
| 27 | + echo "tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT |
| 28 | + fi |
| 29 | +
|
| 30 | + - name: Get previous release date |
| 31 | + id: prev_release |
| 32 | + env: |
| 33 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + run: | |
| 35 | + PREV_TAG=$(gh release list --limit 2 --json tagName -q '.[1].tagName') |
| 36 | + PREV_DATE=$(gh release view "$PREV_TAG" --json publishedAt -q '.publishedAt' | cut -d'T' -f1) |
| 37 | + echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT |
| 38 | + echo "date=$PREV_DATE" >> $GITHUB_OUTPUT |
| 39 | + echo "Previous release: $PREV_TAG (published $PREV_DATE)" |
| 40 | +
|
| 41 | + - name: Check for PRs with wix label |
| 42 | + id: wix_prs |
| 43 | + env: |
| 44 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + run: | |
| 46 | + WIX_PRS=$(gh pr list \ |
| 47 | + --label wix \ |
| 48 | + --state merged \ |
| 49 | + --base master \ |
| 50 | + --search "merged:>=${{ steps.prev_release.outputs.date }}" \ |
| 51 | + --json number,title \ |
| 52 | + --jq '.') |
| 53 | +
|
| 54 | + COUNT=$(echo "$WIX_PRS" | jq 'length') |
| 55 | + echo "Found $COUNT PR(s) with 'wix' label" |
| 56 | +
|
| 57 | + if [ "$COUNT" -eq 0 ]; then |
| 58 | + echo "has_wix=false" >> $GITHUB_OUTPUT |
| 59 | + else |
| 60 | + echo "has_wix=true" >> $GITHUB_OUTPUT |
| 61 | + PR_LIST=$(echo "$WIX_PRS" | jq -r '.[] | "- #\(.number) \(.title)"') |
| 62 | + { |
| 63 | + echo "pr_list<<EOF" |
| 64 | + echo "$PR_LIST" |
| 65 | + echo "EOF" |
| 66 | + } >> $GITHUB_OUTPUT |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Dispatch to engine |
| 70 | + if: steps.wix_prs.outputs.has_wix == 'true' |
| 71 | + env: |
| 72 | + GH_TOKEN: ${{ secrets.ENGINE_GITHUB_TOKEN }} |
| 73 | + VERSION: ${{ steps.version.outputs.tag }} |
| 74 | + PREV_VERSION: ${{ steps.prev_release.outputs.tag }} |
| 75 | + PR_LIST: ${{ steps.wix_prs.outputs.pr_list }} |
| 76 | + run: | |
| 77 | + jq -n \ |
| 78 | + --arg version "$VERSION" \ |
| 79 | + --arg prev_version "$PREV_VERSION" \ |
| 80 | + --arg pr_list "$PR_LIST" \ |
| 81 | + '{ |
| 82 | + event_type: "rnn-version-update", |
| 83 | + client_payload: { |
| 84 | + version: $version, |
| 85 | + prev_version: $prev_version, |
| 86 | + pr_list: $pr_list |
| 87 | + } |
| 88 | + }' | gh api repos/wix-private/mobile-apps-engine/dispatches \ |
| 89 | + --method POST \ |
| 90 | + --input - |
| 91 | +
|
| 92 | + echo "Dispatched rnn-version-update to engine for version $VERSION" |
0 commit comments