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

fix secrets #428

Merged
merged 5 commits into from
Oct 6, 2023
Merged
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
11 changes: 5 additions & 6 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Download the table
if: github.base_ref == 'main'
run: curl -L "docs.google.com/spreadsheets/d/${{ secrets.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv

- uses: dawidd6/action-download-artifact@v2
with:
pr: ${{github.event.pull_request.number}}
Expand All @@ -24,12 +29,6 @@ jobs:
skip_unpack: true
# path: bin/bot
- run: unzip executable.zip -d bin
- uses: dawidd6/action-download-artifact@v2
if: github.base_ref == 'main'
with:
pr: ${{github.event.pull_request.number}}
workflow: CI.yml
name: table

- name: Restart bot
env:
Expand Down
94 changes: 11 additions & 83 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,91 +14,19 @@ env:

jobs:
build_and_test_bot:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Download the table
if: github.base_ref == 'main'
# env:
# SHEET_ID:
# run: curl -L "docs.google.com/spreadsheets/d/${{ secrets['SHEET_ID_${github.base_ref}'] }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv
run: curl -L "docs.google.com/spreadsheets/d/${{ secrets['SHEET_ID_dev'] }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv

# - uses: baptiste0928/cargo-install@v2
# with:
# crate: cargo-bloat
# - run: cd bot && cargo bloat
# env:
# SHEET_ID: ${{ secrets['SHEET_ID_${github.base_ref}'] }}

- name: Test and build release
if: github.base_ref == 'main'
env:
SHEET_ID: ${{ secrets['SHEET_ID_${github.base_ref}'] }}
run: cargo test --release && cargo build --release

- name: Test and build debug
if: github.base_ref == 'dev'
env:
SHEET_ID: ${{ secrets['SHEET_ID_${github.base_ref}'] }}
run: cargo test && cargo build

- name: Move binary
run: mv target/*/bot target

- uses: actions/upload-artifact@v3
with:
name: executable
path: target/bot

- uses: actions/upload-artifact@v3
if: github.base_ref == 'main'
with:
name: table
path: table.csv
uses: ./.github/workflows/build_and_test_bot.yml
with:
release: ${{ github.base_ref == 'main' }}
upload-artifact: true
secrets:
SHEET_ID: ${{ secrets.SHEET_ID }}

build_flutter_apk:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android, armv7-linux-androideabi, x86_64-linux-android, i686-linux-android
- uses: Swatinem/rust-cache@v2
- uses: baptiste0928/cargo-install@v2
with:
crate: flutter_rust_bridge_codegen
- uses: baptiste0928/cargo-install@v2
with:
crate: cargo-ndk
- uses: baptiste0928/cargo-install@v2
with:
crate: cargo-expand
- run: just && flutter build apk --release
env:
SHEET_ID: ${{ secrets['SHEET_ID_${github.base_ref}'] }}
# https://github.com/actions/upload-artifact/issues/294
- uses: actions/upload-artifact@v3
with:
name: apk
if-no-files-found: error
path: app/build/app/outputs/flutter-apk/app-release.apk
uses: ./.github/workflows/build_flutter_apk.yml
with:
upload-artifact: true
secrets:
SHEET_ID: ${{ secrets.SHEET_ID }}

# It should wait untill all checks will pass
auto-merge:
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/build_and_test_bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
workflow_call:
inputs:
release:
required: true
type: boolean
upload-artifact:
required: true
type: boolean

secrets:
SHEET_ID:
required: true

jobs:
build_and_test_bot:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Download the table
if: inputs.release
run: curl -L "docs.google.com/spreadsheets/d/${{ secrets.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv

- name: Test and build release
if: inputs.release
env:
SHEET_ID: ${{ env.SHEET_ID }}
run: cargo test --release && cargo build --release

- name: Test and build debug
if: ${{ !inputs.release }}
env:
SHEET_ID: ${{ env.SHEET_ID }}
run: cargo test && cargo build

- name: Move binary
if: inputs.upload-artifact
run: mv target/*/bot target

- uses: actions/upload-artifact@v3
if: inputs.upload-artifact
with:
name: executable
path: target/bot
54 changes: 54 additions & 0 deletions .github/workflows/build_flutter_apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
on:
workflow_call:
inputs:
# release:
# required: true
# type: boolean
upload-artifact:
required: true
type: boolean

secrets:
SHEET_ID:
required: true

jobs:
build_flutter_apk:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
steps:
- uses: actions/checkout@v3
- uses: extractions/setup-just@v1
- uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android, armv7-linux-androideabi, x86_64-linux-android, i686-linux-android
- uses: Swatinem/rust-cache@v2
- uses: baptiste0928/cargo-install@v2
with:
crate: flutter_rust_bridge_codegen
- uses: baptiste0928/cargo-install@v2
with:
crate: cargo-ndk
- uses: baptiste0928/cargo-install@v2
with:
crate: cargo-expand
- run: just && flutter build apk --release
env:
SHEET_ID: ${{ secrets.SHEET_ID }}
- uses: actions/upload-artifact@v3
if: inputs.upload-artifact
with:
name: apk
if-no-files-found: error
path: app/build/app/outputs/flutter-apk/app-release.apk