Skip to content

push@gradle : no comment #50

push@gradle : no comment

push@gradle : no comment #50

Workflow file for this run

name: Build, Deploy, and APK
on:
push:
branches:
- gradle
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
- name: Build Hugo
run: hugo --minify
- name: Publish to gradle/public
run: |
mkdir -p gradle/public
cp -r public/* gradle/public/
- name: Commit and push changes to gradle/public
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add gradle/public
git commit -m "Update static site content" || echo "No changes to commit"
git push origin gradle
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/gradle'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gradle/public
publish_branch: gh-pages
build-apk:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build APK using Docker
run: |
# Get the repository permalink
REPO_URL="${{ github.event.repository.html_url }}"
# Extract the repo name and format it for Cordova
REPO_NAME=$(basename -s .git "$REPO_URL")
APP_NAME=$(echo "$REPO_NAME" | sed -e 's/-/ /g' -e 's/^./\U&/') # Capitalize first letter and replace '-' with space
PACKAGE_NAME=$(echo "$REPO_URL" | sed 's|https://github.com/||;s|/|.|g;s|.git$||;s|-|.|g;s|[^a-zA-Z0-9.]||g')
echo "Creating Cordova project with:"
echo "App Name: $APP_NAME"
echo "Package Name: com.$PACKAGE_NAME"
docker run --rm -v "${{ github.workspace }}:/github/workspace" -w /github/workspace mobagenie/mgbuild:v1 sh -c "
cordova create com.$PACKAGE_NAME com.$PACKAGE_NAME $APP_NAME &&
rm -rf com.$PACKAGE_NAME/www/* &&
cp -r gradle/public/* com.$PACKAGE_NAME/www &&
cd com.$PACKAGE_NAME &&
cordova platform add android &&
cordova build android --debug"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Archive APK
run: |
# Get the repository permalink
REPO_URL="${{ github.event.repository.html_url }}"
PACKAGE_NAME=$(echo "$REPO_URL" | sed 's|https://github.com/||;s|/|.|g;s|.git$||;s|-|.|g;s|[^a-zA-Z0-9.]||g')
mkdir -p apk
cp -r com.$PACKAGE_NAME/platforms/android/app/build/outputs/apk/debug/*.apk apk/
echo "APK files in apk directory:"
ls apk # List APK files to verify they exist
- name: Set tag and release name
id: set_release_info
run: |
TAG_NAME="release-$(echo $GITHUB_SHA | cut -c1-7)"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "RELEASE_NAME=Release $(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.TAG_NAME }}
release_name: ${{ env.RELEASE_NAME }}
body: "APK build for gradle branch"
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload APK to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: apk/app-debug.apk # Specify the exact APK file name
asset_name: MyApp-debug.apk
asset_content_type: application/vnd.android.package-archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}