|
| 1 | +name: Jusicool CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + flutter_test: |
| 11 | + name: Run flutter test and analyze |
| 12 | + runs-on: macos-latest |
| 13 | + steps: |
| 14 | + |
| 15 | + - name: Checkout Flutter repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup Java |
| 19 | + uses: actions/setup-java@v3.12.0 |
| 20 | + with: |
| 21 | + distribution: 'oracle' |
| 22 | + java-version: '17' |
| 23 | + |
| 24 | + - name: Setup Flutter |
| 25 | + uses: subosito/flutter-action@v2 |
| 26 | + with: |
| 27 | + channel: 'stable' |
| 28 | + |
| 29 | + - name: Checking Flutter Version |
| 30 | + run: flutter --version |
| 31 | + |
| 32 | + - name: Install Dependencies |
| 33 | + run: flutter pub get |
| 34 | + |
| 35 | + - name: Analyze project source |
| 36 | + run: flutter analyze |
| 37 | + |
| 38 | + - name: Test Package |
| 39 | + run: flutter packages pub publish --dry-run |
| 40 | + |
| 41 | + - name: Set timestamp |
| 42 | + id: timestamp |
| 43 | + run: echo "TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV |
| 44 | + |
| 45 | + - name: Notify Success for Push |
| 46 | + if: github.event_name == 'push' && success() |
| 47 | + env: |
| 48 | + TIMESTAMP: ${{ env.TIMESTAMP }} |
| 49 | + SUCCESS_FLUTTER_IMAGE: ${{ secrets.SUCCESS_FLUTTER_IMAGE }} |
| 50 | + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 51 | + run: | |
| 52 | + DATA=$(cat <<EOF |
| 53 | + { |
| 54 | + "content": "<@749992025985777755>, <@1055126447246823518>, <@1075320294446731326>", |
| 55 | + "embeds": [ |
| 56 | + { |
| 57 | + "title": "CI ์ฑ๊ณต :)", |
| 58 | + "description": "** COMMIT MESSAGE **\n> [${{ github.event.head_commit.message }}](${{ github.event.head_commit.url }})\n", |
| 59 | + "color": 46335, |
| 60 | + "timestamp": "${{ env.TIMESTAMP }}", |
| 61 | + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", |
| 62 | + "author": { |
| 63 | + "name": "${{ github.event.sender.login }}", |
| 64 | + "url": "${{ github.event.sender.html_url }}", |
| 65 | + "icon_url": "${{ github.event.sender.avatar_url }}" |
| 66 | + }, |
| 67 | + "thumbnail": { |
| 68 | + "url": "${{ github.event.sender.avatar_url }}" |
| 69 | + }, |
| 70 | + "fields": [ |
| 71 | + { |
| 72 | + "name": "Repository", |
| 73 | + "value": "> [${{ github.repository }}](https://github.com/${{ github.repository }})\n" |
| 74 | + }, |
| 75 | + { |
| 76 | + "name": "Branch", |
| 77 | + "value": "> [${{ github.ref }}](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }})", |
| 78 | + "inline": false |
| 79 | + }, |
| 80 | + { |
| 81 | + "name": "Workflow", |
| 82 | + "value": "> [CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})", |
| 83 | + "inline": false |
| 84 | + } |
| 85 | + ] |
| 86 | + } |
| 87 | + ] |
| 88 | + } |
| 89 | + EOF |
| 90 | + ) |
| 91 | + curl -X POST -H 'Content-type:application/json' -d "$DATA" "${{ secrets.DISCORD_WEBHOOK_URL }}" |
| 92 | +
|
| 93 | + - name: Notify Success for PR |
| 94 | + if: github.event_name == 'pull_request' && success() |
| 95 | + env: |
| 96 | + TIMESTAMP: ${{ env.TIMESTAMP }} |
| 97 | + SUCCESS_FLUTTER_IMAGE: ${{ secrets.SUCCESS_FLUTTER_IMAGE }} |
| 98 | + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 99 | + run: | |
| 100 | + DATA=$(cat <<EOF |
| 101 | + { |
| 102 | + "content": "<@749992025985777755>, <@1055126447246823518>, <@1075320294446731326>", |
| 103 | + "embeds": [ |
| 104 | + { |
| 105 | + "title": "CI ์ฑ๊ณต :)", |
| 106 | + "description": "** Pull Request **\n> [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})\n", |
| 107 | + "color": 46335, |
| 108 | + "timestamp": "${{ env.TIMESTAMP }}", |
| 109 | + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", |
| 110 | + "author": { |
| 111 | + "name": "${{ github.event.sender.login }}", |
| 112 | + "url": "${{ github.event.sender.html_url }}" |
| 113 | + }, |
| 114 | + "thumbnail": { |
| 115 | + "url": "${{ github.event.sender.avatar_url }}" |
| 116 | + }, |
| 117 | + "fields": [ |
| 118 | + { |
| 119 | + "name": "Repository", |
| 120 | + "value": "> [${{ github.repository }}](https://github.com/${{ github.repository }})\n" |
| 121 | + }, |
| 122 | + { |
| 123 | + "name": "Branch", |
| 124 | + "value": "> [${{ github.ref }}](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }})", |
| 125 | + "inline": false |
| 126 | + }, |
| 127 | + { |
| 128 | + "name": "Workflow", |
| 129 | + "value": "> [CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})", |
| 130 | + "inline": false |
| 131 | + } |
| 132 | + ] |
| 133 | + } |
| 134 | + ] |
| 135 | + } |
| 136 | + EOF |
| 137 | + ) |
| 138 | + curl -X POST -H 'Content-type:application/json' -d "$DATA" "${{ secrets.DISCORD_WEBHOOK_URL }}" |
| 139 | +
|
| 140 | + - name: Notify Failure |
| 141 | + if: failure() |
| 142 | + env: |
| 143 | + TIMESTAMP: ${{ env.TIMESTAMP }} |
| 144 | + FAIL_FLUTTER_IMAGE: ${{ secrets.FAIL_FLUTTER_IMAGE }} |
| 145 | + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} |
| 146 | + run: | |
| 147 | + DATA=$(cat <<EOF |
| 148 | + { |
| 149 | + "content": "<@749992025985777755>, <@1055126447246823518>, <@1075320294446731326>", |
| 150 | + "embeds": [ |
| 151 | + { |
| 152 | + "title": "CI ์คํจ :(", |
| 153 | + "description": "** ${{ |
| 154 | + github.event_name == 'push' |
| 155 | + && 'COMMIT MESSAGE' || 'Pull Request' }} **\n> [${{ |
| 156 | + github.event_name == 'push' |
| 157 | + && github.event.head_commit.message || |
| 158 | + github.event.pull_request.title }}](${{ |
| 159 | + github.event_name == 'push' |
| 160 | + && github.event.head_commit.url || |
| 161 | + github.event.pull_request.html_url }})\n", |
| 162 | + "color": 16711680, |
| 163 | + "timestamp": "${{ env.TIMESTAMP }}", |
| 164 | + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", |
| 165 | + "author": { |
| 166 | + "name": "${{ github.event.sender.login }}", |
| 167 | + "url": "${{ github.event.sender.html_url }}" |
| 168 | + }, |
| 169 | + "thumbnail": { |
| 170 | + "url": "${{ github.event.sender.avatar_url }}" |
| 171 | + }, |
| 172 | + "fields": [ |
| 173 | + { |
| 174 | + "name": "Repository", |
| 175 | + "value": "> [${{ github.repository }}](https://github.com/${{ github.repository }})\n" |
| 176 | + }, |
| 177 | + { |
| 178 | + "name": "Branch", |
| 179 | + "value": "> [${{ github.ref }}](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }})", |
| 180 | + "inline": false |
| 181 | + }, |
| 182 | + { |
| 183 | + "name": "Workflow", |
| 184 | + "value": "> [CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})", |
| 185 | + "inline": false |
| 186 | + } |
| 187 | + ] |
| 188 | + } |
| 189 | + ] |
| 190 | + } |
| 191 | + EOF |
| 192 | + ) |
| 193 | + curl -X POST -H 'Content-type:application/json' -d "$DATA" "${{ secrets.DISCORD_WEBHOOK_URL }}" |
0 commit comments