Skip to content

Commit

Permalink
[1.1.0/AN_CD] Discord로 alpha 버전 apk 전달 (#290)
Browse files Browse the repository at this point in the history
* 🎉 Chore: PR_Comment_Notification.yml

PR Comment 에 '/noti' 를 포함할 경우 Andorid 채널 혹은 Backend 채널로 노티가 간다

* 🎉 Chore: �Avatar, Content, Description 수정

* docs: README v0.1

* CD: discord로 apk 전달

* CD: cd되는지 확인

* ci: artifact 버전 v3로 수정

* test

* build : 병렬처리

* Revert "Merge branch 'main' into an/cd/send_to_discord"

This reverts commit 925c8db, reversing
changes made to 346391c.

* ci: google-service추가

* ci: 버저닝 label 추가
[1.1.0/AN_CD] Discord로 alpha 버전 apk 전달 (#290)

* 🎉 Chore: PR_Comment_Notification.yml

PR Comment 에 '/noti' 를 포함할 경우 Andorid 채널 혹은 Backend 채널로 노티가 간다

* 🎉 Chore: �Avatar, Content, Description 수정

* docs: README v0.1

* CD: discord로 apk 전달

* CD: cd되는지 확인

* ci: artifact 버전 v3로 수정

* test

* build : 병렬처리

* Revert "Merge branch 'main' into an/cd/send_to_discord"

This reverts commit 925c8db, reversing
changes made to 346391c.

* ci: google-service추가

* ci: 버저닝 label 추가
  • Loading branch information
murjune committed Sep 11, 2024
1 parent 9b80faa commit d2365ff
Show file tree
Hide file tree
Showing 5 changed files with 542 additions and 47 deletions.
49 changes: 40 additions & 9 deletions .github/actions/add_labels/action.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,81 @@
name: Add Labels Action

permissions:
contents: read
pull-requests: write
description: "Add labels to a pull request based on its title"

inputs:
title:
description: "title of the pull request or issue"
required: true

runs:
using: 'composite'
steps:

- name: Input title
shell: bash
run: |
echo "Input Title: ${{ inputs.title }}"
- name: add FEAT ✨ labels
uses: actions-ecosystem/action-add-labels@v1
if: ${{ contains(github.event.pull_request.title, 'FEAT') }}
if: ${{ contains(inputs.title, 'FEAT') }}
with:
labels: |
AN_FEAT ✨
- name: add UI 🎨 labels
uses: actions-ecosystem/action-add-labels@v1
if: ${{ contains(github.event.pull_request.title, 'UI') }}
if: ${{ contains(inputs.title, 'UI') }}
with:
labels: |
AN_UI 🎨
- name: add REFACTOR ✍️ label
uses: actions-ecosystem/action-add-labels@v1
if: ${{ contains(github.event.pull_request.title, 'REFACTOR') }}
if: ${{ contains(inputs.title, 'REFACTOR') }}
with:
labels: |
AN_REFACTOR ✍️
- name: add FIX 🐛 label
uses: actions-ecosystem/action-add-labels@v1
if: ${{ contains(github.event.pull_request.title, 'FIX') }}
if: ${{ contains(inputs.title, 'FIX') }}
with:
labels: |
AN_FIX 🐛
- name: add CI/CD 🤖 label
uses: actions-ecosystem/action-add-labels@v1
if: ${{ contains(github.event.pull_request.title, 'CI') || contains(github.event.pull_request.title, 'CD') }}
if: ${{ contains(inputs.title, 'CI') || contains(inputs.title, 'CD') }}
with:
labels: |
AN_CI/CD 🤖
- name: add CONFIG 🧭 label
uses: actions-ecosystem/action-add-labels@v1
if: ${{ contains(github.event.pull_request.title, 'CONFIG') }}
if: ${{ contains(inputs.title, 'CONFIG') }}
with:
labels: |
AN_CONFIG 🧭
- name: Extract Version Name
shell: bash
env:
title: ${{ inputs.title }}
run: |
version=$(echo '${{ env.title }}' | grep -oP '\d+\.\d+\.\d+')
if [ -z "$version" ]; then
echo "No version found in the title."
echo "version=none" >> $GITHUB_ENV
else
echo "version=v$version" >> $GITHUB_ENV
fi
- name: Add version 🏷️ label
uses: actions-ecosystem/action-add-labels@v1
if: ${{ env.version != 'none' }} # 버전이 존재할 때만 실행
with:
labels: |
${{ env.version }} 🏷️
229 changes: 229 additions & 0 deletions .github/workflows/Android_Develop_PR_Builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
name: Android PR Builder

on:
pull_request:
branches: [ an/develop ]
push:
branches: [ an/develop ]


defaults:
run:
working-directory: ./android

jobs:
ktlintCheck:
name: ktLint Check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17

- name: Create Local Properties
run: touch local.properties

- name: Access Local Properties
env:
POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }}
run: |
echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Lint Check
run: ./gradlew ktlintCheck

testAlphaUnitTest:
name: Test Alpha Unit Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17

- name: Create Google-Services.json
env:
GOOGLE_SERVICES_ALPHA: ${{ secrets.GOOGLE_SERVICES_ALPHA }}
GOOGLE_SERVICES_BETA: ${{ secrets.GOOGLE_SERVICES_BETA }}
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: |
touch ./app/src/debug/google-services.json
touch ./app/src/alpha/google-services.json
touch ./app/src/beta/google-services.json
mkdir ./app/src/release
touch ./app/src/release/google-services.json
echo $GOOGLE_SERVICES_ALPHA >> ./app/src/debug/google-services.json
echo $GOOGLE_SERVICES_ALPHA >> ./app/src/alpha/google-services.json
echo $GOOGLE_SERVICES_BETA >> ./app/src/beta/google-services.json
echo $GOOGLE_SERVICES >> ./app/src/release/google-services.json
- name: Create Local Properties
run: touch local.properties

- name: Access Local Properties
env:
POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }}
run: |
echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: run alpha unit test
run: ./gradlew testAlphaUnitTest

Distribution:
name: Alpha APK to Discord
runs-on: ubuntu-latest
needs: [ ktlintCheck, testAlphaUnitTest ]
if: ${{ github.event.pull_request.merged == true }} # PR이 머지되었을 때만 실행
steps:
- uses: actions/checkout@v4
- name: Gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17

- name: Create Google-Services.json
env:
GOOGLE_SERVICES_ALPHA: ${{ secrets.GOOGLE_SERVICES_ALPHA }}
GOOGLE_SERVICES_BETA: ${{ secrets.GOOGLE_SERVICES_BETA }}
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: |
touch ./app/src/debug/google-services.json
touch ./app/src/alpha/google-services.json
touch ./app/src/beta/google-services.json
mkdir ./app/src/release
touch ./app/src/release/google-services.json
echo $GOOGLE_SERVICES_ALPHA >> ./app/src/debug/google-services.json
echo $GOOGLE_SERVICES_ALPHA >> ./app/src/alpha/google-services.json
echo $GOOGLE_SERVICES_BETA >> ./app/src/beta/google-services.json
echo $GOOGLE_SERVICES >> ./app/src/release/google-services.json
- name: Check google-services.json content
run: cat ./app/src/debug/google-services.json

- name: Create Local Properties
run: touch local.properties

- name: Access Local Properties
env:
POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }}
# POKE_RELEASE_URL: ${{ secrets.HOST_RELEASE_URI }}
# KEYSTORE_PATH: ${{ secrets.KEYSTORE_PATH }}
# STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
# KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
# KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
# STORE_FILE: ${{ secrets.STORE_FILE }}
run: |
echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties
# echo STORE_PASSWORD= $STORE_PASSWORD >> local.properties
# echo KEY_PASSWORD= $KEY_PASSWORD >> local.properties
# echo KEY_ALIAS= $KEY_ALIAS >> local.properties
# echo STORE_FILE= $STORE_FILE >> local.properties
# - name: Create Key Store
# env:
# KEY_STORE_BASE_64: ${{secrets.KEY_STORE_BASE_64}}
# run: |
# echo "$KEY_STORE_BASE_64" | base64 -d > ./funch_key_store.jks

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build alpha APK
run: ./gradlew assembleAlpha

- name: Upload alpha APK artifact
uses: actions/upload-artifact@v4
with:
name: android-artifact
path: android/app/build/outputs/apk/alpha/
if-no-files-found: error

- name: Check APK existence
run: ls -al app/build/outputs/apk/alpha/

- name: Extract Version Name
env:
title: ${{ github.event.pull_request.title }}
run: |
version=$(echo '${{ env.title }}' | grep -oP '\d+\.\d+\.\d+')
echo "version=v$version" >> $GITHUB_ENV
- name: Send alpha version APK to Discord with Embeds
env:
DISCORD_WEBHOOK_URL: ${{ secrets.AlPHA_APK_DISCORD_WEB_HOOK }}
VERSION: ${{ env.version }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
CONTENT="최신 개발 버전 APK 가 나왔어요!🎉
[배포 버전] : $VERSION!
[해당 PR 제목] : $PR_TITLE"
EMBED=$(jq -n \
--arg title "PR Merged: $PR_TITLE" \
--arg url "$PR_URL" \
--arg description "Version: $VERSION 🎉" \
'{
"title": $title,
"url": $url,
"description": $description,
"color": 3066993
}'
)
PAYLOAD=$(jq -n \
--arg content "$CONTENT" \
--argjson embeds "[$EMBED]" \
'{
"content": $content,
"embeds": $embeds
}'
)
curl -F "payload_json=$PAYLOAD" \
-F "file=@app/build/outputs/apk/alpha/app-alpha.apk" \
$DISCORD_WEBHOOK_URL
Loading

0 comments on commit d2365ff

Please sign in to comment.