Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,12 @@ jobs:
run: |
echo "BUILDSTAMP=$(date -u +'%Y-%m-%d_%H-%M' -d"$(stat -c %y ./build/${{ env.BUILD_TYPE }}/total-conversion-build.user.js)")" >> "$GITHUB_ENV"

- name: Push build artifacts to website
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
if: ${{ env.WEBSITE_REPO != '' }}
uses: dmnemec/copy_file_to_another_repo_action@main
with:
source_file: "./build/${{ env.BUILD_TYPE }}/."
destination_repo: ${{ secrets.WEBSITE_REPO }}
destination_branch: master
destination_folder: 'static/build/${{ env.ARCHIVE_DIR }}/${{ env.BUILDSTAMP }}/'
user_email: '[email protected]'
user_name: 'IITC Updates'
commit_message: '🤖 New IITC ${{ env.BUILD_TYPE }} build from https://github.com/${{ github.repository }}/commit/${{ github.sha }}'

- uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "./build/${{ env.BUILD_TYPE }}/*.zip,./build/${{ env.BUILD_TYPE }}/*.apk"
generateReleaseNotes: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: Send APK to Telegram
Expand All @@ -88,3 +72,21 @@ jobs:
TEXT="🤖 *New IITC Mobile ${{ env.BUILD_TYPE }} build: *[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})"
APIPARAMS="-F parse_mode=MarkdownV2 -F disable_notification=true -F chat_id=${{ env.TG_CHAT_ID }} https://api.telegram.org/bot${{ env.TG_BOT_TOKEN }}/sendDocument"
curl -s -F document=@"${{ env.ARTIFACT_IITC_MOBILE }}" -F caption="$TEXT" $APIPARAMS

- name: Save PR metadata
run: |
mkdir artifact
mv ./build/${{ env.BUILD_TYPE }} ./artifact/build
mkdir -p ./artifact/.metadata
echo ${{ env.BUILD_TYPE }} > ./artifact/.metadata/build_type
echo ${{ github.sha }} > ./artifact/.metadata/commit
echo $( ls ./artifact/build/ | grep '.apk' ) > ./artifact/.metadata/apk_filename
echo $( ls ./artifact/build/ | grep '.zip' ) > ./artifact/.metadata/zip_filename
echo $(date -u +'%Y-%m-%d_%H-%M' -d"$(stat -c %y ./artifact/build/total-conversion-build.user.js)") > ./artifact/.metadata/buildstamp

- uses: actions/upload-artifact@v2
with:
name: build
path: |
./artifact/.metadata/
./artifact/build/
5 changes: 3 additions & 2 deletions .github/workflows/build_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
java-version: '11'
cache: 'gradle'

- uses: actions/setup-python@v4
Expand All @@ -39,7 +39,8 @@ jobs:
run: |
mv ./build/${{ env.BUILD_TYPE }} ./build/build
mkdir -p ./build/.metadata
echo ${{ github.event.number }} > ./build/.metadata/number
echo "PR" > ./build/.metadata/build_type
echo ${{ github.event.number }} > ./build/.metadata/pr_number
echo ${{ github.event.pull_request.head.sha }} > ./build/.metadata/commit
echo $( ls ./build/build/ | grep '.apk' ) > ./build/.metadata/apk_filename
echo $( ls ./build/build/ | grep '.zip' ) > ./build/.metadata/zip_filename
Expand Down
32 changes: 5 additions & 27 deletions .github/workflows/merge_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,14 @@ on:

jobs:
if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ env.WEBSITE_REPO != '' }}
with:
repository: ${{ secrets.WEBSITE_REPO }}
ref: 'master'
token: ${{ secrets.API_TOKEN_GITHUB }}

- name: Setup git config
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ env.WEBSITE_REPO != '' }}
run: |
git config user.name "userz"
git config user.email "<>"

- name: Delete old build artifacts
- name: Send build artifacts to website
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ env.WEBSITE_REPO != '' }}
run: |
git rm -r static/build/artifact/PR${{ github.event.number }}/
git commit -m "🤖 PR №${{ github.event.number }} merged, deleting old build artifacts"

- run: git push origin master
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ env.WEBSITE_REPO != '' }}
curl -X POST https://api.github.com/repos/${{ secrets.WEBSITE_REPO }}/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.API_TOKEN_GITHUB }} \
--data '{"event_type": "delete_iitc_pr_build", "client_payload": { "repo": {"pr_number": "${{ github.event.number }}" }}'
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
name: Upload PR
name: Send build to website

# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ["Build PR"]
workflows: ["Build PR", "Build IITC and push artifacts"]
types:
- completed

jobs:
upload:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Download artifact'
uses: actions/github-script@v6
Expand All @@ -39,42 +37,31 @@ jobs:
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/build.zip`, Buffer.from(download.data));

core.exportVariable('REPO_OWNER', context.repo.owner);
core.exportVariable('REPO_NAME', context.repo.repo);
core.exportVariable('ARTIFACT_ID', matchArtifact.id);

- name: 'Unzip artifact'
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ env.WEBSITE_REPO != '' }}
if: ${{ env.WEBSITE_REPO != '' && github.event.workflow_run.event == 'pull_request' }}
run: unzip build.zip

- name: Set env
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ env.WEBSITE_REPO != '' }}
if: ${{ env.WEBSITE_REPO != '' && github.event.workflow_run.event == 'pull_request' }}
run: |
echo "PR_NUMBER=$(cat ./.metadata/number)" >> "$GITHUB_ENV"
echo "COMMIT_HASH=$(cat ./.metadata/commit)" >> "$GITHUB_ENV"
echo "BUILD_APK_FILENAME=$(cat ./.metadata/apk_filename)" >> "$GITHUB_ENV"
echo "BUILD_ZIP_FILENAME=$(cat ./.metadata/zip_filename)" >> "$GITHUB_ENV"
echo "BUILDSTAMP=$(cat ./.metadata/buildstamp)" >> "$GITHUB_ENV"

- name: Push build artifacts to website
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
if: ${{ env.WEBSITE_REPO != '' }}
uses: dmnemec/copy_file_to_another_repo_action@main
with:
source_file: "./build/."
destination_repo: ${{ secrets.WEBSITE_REPO }}
destination_branch: master
destination_folder: 'static/build/artifact/PR${{ env.PR_NUMBER }}/'
user_email: '[email protected]'
user_name: 'IITC Updates'
commit_message: '🤖 New build PR №${{ env.PR_NUMBER }} from https://github.com/${{ github.repository }}/commit/${{ github.sha }}'

- name: Comment with build url
- name: Comment with build url for PR
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ env.WEBSITE_REPO != '' }}
if: ${{ env.WEBSITE_REPO != '' && github.event.workflow_run.event == 'pull_request' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr_release
Expand All @@ -87,3 +74,13 @@ jobs:
| [`${{ env.BUILD_ZIP_FILENAME }}`](https://github.com/${{ secrets.WEBSITE_REPO }}/raw/master/static/build/artifact/PR${{ env.PR_NUMBER }}/${{ env.BUILD_ZIP_FILENAME }}) | ${{ env.COMMIT_HASH }} |

[See build on website](https://iitc.app/build/artifact/PR${{ env.PR_NUMBER }}/)

- name: Send build artifacts to website
env:
WEBSITE_REPO: ${{ secrets.WEBSITE_REPO }}
if: ${{ env.WEBSITE_REPO != '' }}
run: |
curl -X POST https://api.github.com/repos/${{ secrets.WEBSITE_REPO }}/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.API_TOKEN_GITHUB }} \
--data '{"event_type": "new_iitc_build", "client_payload": { "repo": {"owner": "${{ env.REPO_OWNER }}", "repo": "${{ env.REPO_NAME }}"}, "artifact_id": "${{ env.ARTIFACT_ID }}" }}'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ It is available for desktop browsers, such as Firefox and Chrome, and as a mobil
**[Website](https://iitc.app/) | [Documentation](https://iitc-ce.rtfd.io/) | [Telegram channel](https://t.me/iitc_news)**




## Users

Install IITC: https://iitc.app/
Expand Down