-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
178 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
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 && | ||
ls && | ||
ls www && | ||
cordova platform add android && | ||
cordova build android --debug" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Archive APKs | ||
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 }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,74 @@ | ||
name: Build, Deploy, and APK | ||
# Sample workflow for building and deploying a Hugo site to GitHub Pages | ||
name: Deploy Hugo site to Pages | ||
|
||
on: | ||
# Runs on pushes targeting the default branch | ||
push: | ||
branches: | ||
- gradle | ||
branches: ["gradle"] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
# Default to bash | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
# Build job | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
HUGO_VERSION: 0.128.0 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Install Hugo CLI | ||
run: | | ||
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | ||
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb | ||
- name: Install Dart Sass | ||
run: sudo snap install dart-sass | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
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 | ||
- name: Setup Pages | ||
id: pages | ||
uses: actions/configure-pages@v5 | ||
- name: Install Node.js dependencies | ||
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | ||
- name: Build with Hugo | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Deploy to GitHub Pages | ||
if: github.ref == 'refs/heads/gradle' | ||
uses: peaceiris/actions-gh-pages@v3 | ||
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache | ||
HUGO_ENVIRONMENT: production | ||
run: | | ||
hugo \ | ||
--minify \ | ||
--baseURL "${{ steps.pages.outputs.base_url }}/" | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./gradle/public | ||
publish_branch: gh-pages | ||
path: ./public | ||
|
||
build-apk: | ||
# Deployment job | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
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 && | ||
ls && | ||
ls www && | ||
cordova platform add android && | ||
cordova build android --debug" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Archive APKs | ||
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 }} | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
gradle/* | ||
/gradle/* | ||
public/* | ||
/public/* | ||
ssh_setup.sh | ||
|