From 779db698139ec00e7766f328da236563e3632c5e Mon Sep 17 00:00:00 2001 From: Mariana Souza Date: Thu, 28 Nov 2024 15:10:52 -0500 Subject: [PATCH] Add slack notification --- .github/workflows/ios-sdk-ci.yml | 197 ++++++++++++++++++++----------- .github/workflows/test.yml | 41 +++++++ 2 files changed, 169 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ios-sdk-ci.yml b/.github/workflows/ios-sdk-ci.yml index f1449c3..cf2101c 100644 --- a/.github/workflows/ios-sdk-ci.yml +++ b/.github/workflows/ios-sdk-ci.yml @@ -7,79 +7,138 @@ on: - "v[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z0-9]+)?" jobs: - setup: - name: "Setup" - runs-on: macos-13 - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Install ruby and gem dependencies - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.0.7 - bundler-cache: true # runs 'bundle install' and caches installed gems automatically + # setup: + # name: "Setup" + # runs-on: macos-13 + # steps: + # - name: Checkout Code + # uses: actions/checkout@v4 + # - name: Install ruby and gem dependencies + # uses: ruby/setup-ruby@v1 + # with: + # ruby-version: 3.0.7 + # bundler-cache: true # runs 'bundle install' and caches installed gems automatically - sdk-tests: - name: "SDK Tests" - runs-on: macos-13 - needs: [setup] - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Bundle install - run: bundle install - - name: Run Tests - run: bundle exec fastlane tests - - name: Store Artifacts - uses: actions/upload-artifact@v4 - with: - name: test-results - path: ./fastlane/test_output + # sdk-tests: + # name: "SDK Tests" + # runs-on: macos-13 + # needs: [setup] + # steps: + # - name: Checkout Code + # uses: actions/checkout@v4 + # - name: Bundle install + # run: bundle install + # - name: Run Tests + # run: bundle exec fastlane tests + # - name: Store Artifacts + # uses: actions/upload-artifact@v4 + # with: + # name: test-results + # path: ./fastlane/test_output - build-demo-swift: - name: "Build Demo Swift" - runs-on: macos-14 - needs: [setup, sdk-tests] - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Bundle install - run: bundle install - - name: Build Demo Swift - id: build-demo-swift - run: bundle exec fastlane demo_swift - - name: Store Artifacts - uses: actions/upload-artifact@v4 - with: - name: demo-swift - path: ./demo-ios-swift/Pods - - name: Store build log - uses: actions/upload-artifact@v4 - with: - name: build-log-swift - path: /Users/runner/Library/Logs/gym + # build-demo-swift: + # name: "Build Demo Swift" + # runs-on: macos-14 + # needs: [setup, sdk-tests] + # steps: + # - name: Checkout Code + # uses: actions/checkout@v4 + # - name: Bundle install + # run: bundle install + # - name: Build Demo Swift + # id: build-demo-swift + # run: bundle exec fastlane demo_swift + # - name: Store Artifacts + # uses: actions/upload-artifact@v4 + # with: + # name: demo-swift + # path: ./demo-ios-swift/Pods + # - name: Store build log + # uses: actions/upload-artifact@v4 + # with: + # name: build-log-swift + # path: /Users/runner/Library/Logs/gym - build-demo-objc: - name: "Build Demo Objective-C" - runs-on: macos-14 - env: - FL_OUTPUT_DIR: output - needs: [setup, sdk-tests] + # build-demo-objc: + # name: "Build Demo Objective-C" + # runs-on: macos-14 + # env: + # FL_OUTPUT_DIR: output + # needs: [setup, sdk-tests] + # steps: + # - name: Checkout Code + # uses: actions/checkout@v4 + # - name: Bundle install + # run: bundle install + # - name: Build Demo Objective-C + # run: bundle exec fastlane demo_objc + # - name: Store Artifacts + # uses: actions/upload-artifact@v4 + # with: + # name: demo-objc + # path: ./demo-ios-objc/Pods + # - name: Store build log + # uses: actions/upload-artifact@v4 + # with: + # name: build-log-objc + # path: /Users/runner/Library/Logs/gym + + slack-notification: + runs-on: ubuntu-22.04 + # needs: [build-demo-swift, build-demo-objc] + permissions: + id-token: write steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Bundle install - run: bundle install - - name: Build Demo Objective-C - run: bundle exec fastlane demo_objc - - name: Store Artifacts - uses: actions/upload-artifact@v4 + - name: Successful Release Post to Slack + uses: slackapi/slack-github-action@v2.0.0 + if: ${{ success() && (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }} with: - name: demo-objc - path: ./demo-ios-objc/Pods - - name: Store build log - uses: actions/upload-artifact@v4 + method: chat.postMessage + token: "${{ secrets.SLACK_MESSENGER_APP_TOKEN }}" + payload: | + channel: "${{ secrets.ALERTS_SLACK_CHANNEL_ID }}" + text: "iOS SDK release: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + blocks: + - type: "header" + text: + type: "plain_text" + text: ":certified: iOS SDK release" + emoji: true + - type: "section" + fields: + - type: "mrkdwn" + text: "*Status:*\n${{ job.status }}" + - type: "mrkdwn" + text: "*Branch:*\n${{ github.ref_name }}" + - type: "mrkdwn" + text: "*Author:*\n${{ github.actor || github.triggering_actor }}" + - type: "mrkdwn" + text: ":white_check_mark: *iOS SDK release:*\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + - name: Build failure Post to Slack + uses: slackapi/slack-github-action@v2.0.0 + # if: ${{ failure() && github.event_name == 'pull_request' }} + if: ${{ always()}} with: - name: build-log-objc - path: /Users/runner/Library/Logs/gym + method: chat.postMessage + token: "${{ secrets.SLACK_MESSENGER_APP_TOKEN }}" + payload: | + channel: "${{ secrets.ALERTS_SLACK_CHANNEL_ID }}" + text: "iOS SDK release: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + blocks: + - type: "header" + text: + type: "plain_text" + text: ":certified: iOS SDK release" + emoji: true + - type: "section" + fields: + - type: "mrkdwn" + text: "*Status:*\n${{ job.status }}" + - type: "mrkdwn" + text: "*Branch:*\n${{ github.ref_name }}" + - type: "mrkdwn" + text: "*Author:*\n${{ github.actor || github.triggering_actor }}" + - type: "mrkdwn" + text: ":x: *iOS SDK release:*\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..091a218 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: "TEST" + +on: + pull_request: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z0-9]+)?" + +jobs: + slack-notification: + runs-on: ubuntu-22.04 + # needs: [build-demo-swift, build-demo-objc] + permissions: + id-token: write + steps: + - name: Build failure Post to Slack + uses: slackapi/slack-github-action@v2.0.0 + if: ${{ always()}} + with: + method: chat.postMessage + token: "${{ secrets.SLACK_MESSENGER_APP_TOKEN }}" + payload: | + channel: "${{ secrets.ALERTS_SLACK_CHANNEL_ID }}" + text: "iOS SDK release: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + blocks: + - type: "header" + text: + type: "plain_text" + text: ":certified: iOS SDK release" + emoji: true + - type: "section" + fields: + - type: "mrkdwn" + text: "*Status:*\n${{ job.status }}" + - type: "mrkdwn" + text: "*Branch:*\n${{ github.ref_name }}" + - type: "mrkdwn" + text: "*Author:*\n${{ github.actor || github.triggering_actor }}" + - type: "mrkdwn" + text: ":x: *iOS SDK release:*\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" +