Cashier Release #92
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update HTML with APK Link After Asset Upload | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| wait-for-asset: | |
| name: Wait for APK Upload and Update HTML | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check Release Name | |
| if: ${{ github.event.release.name != 'Cashier Release' }} | |
| run: | | |
| echo "Release name does not match. Exiting build." | |
| exit 1 | |
| - name: Continue build if release name matches | |
| if: ${{ github.event.release.name == 'Cashier Release' }} | |
| run: echo "Release name matches! Running the rest of the job..." | |
| # Step 1: Wait for a fixed delay (e.g., 3 minutes) after the release creation | |
| - name: Wait for APK Upload Delay | |
| run: | | |
| echo "Waiting for 3 minutes to allow APK upload..." | |
| sleep 180 # 3 minutes delay | |
| # Step 2: Checkout the repository | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| # Step 3: Continue with the existing APK check and update HTML | |
| - name: Wait for APK Asset and Update HTML | |
| run: | | |
| RELEASE_ID=${{ github.event.release.id }} | |
| REPO=${{ github.repository }} | |
| echo "Checking APK upload in release $RELEASE_ID in $REPO..." | |
| # Check if the APK has been uploaded (retry logic can still be used here) | |
| ASSETS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/$REPO/releases/$RELEASE_ID" | jq -r '.assets') | |
| if [ "$ASSETS" != "[]" ] && echo "$ASSETS" | grep -q ".apk"; then | |
| APK_URL=$(echo "$ASSETS" | jq -r '.[] | select(.name | endswith(".apk")) | .browser_download_url') | |
| echo "APK detected: $APK_URL" | |
| echo "apk_url=$APK_URL" >> $GITHUB_ENV | |
| else | |
| echo "APK not found. Exiting." | |
| exit 1 | |
| fi | |
| # Checkout repository and update HTML as in your existing code | |
| FILE="index.html" | |
| echo "Updating $FILE with APK URL: $APK_URL" | |
| sed -i "s|onclick=\"window.location.href='.*';\"|onclick=\"window.location.href='$APK_URL';\"|g" $FILE | |
| cat $FILE | |
| # Step 4: Commit and Push Changes | |
| - name: Commit and Push Changes | |
| env: | |
| PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add index.html | |
| git commit -m "Update APK link in index.html for release ${{ github.event.release.tag_name }}" | |
| git push "https://${PAT_TOKEN}@github.com/${{ github.repository }}.git" HEAD:main |