我在JSON文件中有2个秘密,我不想推送到我的GitHub Repo,但是我需要它来使用GitHub动作构建我的apk。
FileName: app_config.json
来自Root的FilePath: config / app_config.json
{
"secret1":"abc",
"secret2" : "def",
}
这就是我想出的:
我分两步执行此操作:
- uses: actions/checkout@v1
- name: base64-to-file
id: write_file
uses: timheuer/base64-to-file@v1.0.3
with:
# Name of the file when written to temp location
fileName: 'app_config.json'
# The base64 encoded string
encodedString: ${{ secrets.APP_CONFIG }}
第2步:这是我正在使用的代码
(a)创建一个名为“ config”的文件夹
(b)将文件从该位置(已解码的位置)移动到“ config”文件夹中
- name: Inject env variables
run: |
mkdir -p ${{ github.workspace }}/config
mv ${{ steps.write_file.outputs.filePath }} ${{ github.workspace }}/config/
构建此工作流程时,这部分没有出现任何错误,但是稍后在运行“ Flutter Test”(运行应用程序的测试)时,此文件夹无法识别。
错误:
Error: unable to find directory entry in pubspec.yaml: /home/runner/work/<my_repo_name>/<my_repo_name>/config/
但是我不只是创建配置文件夹吗?为什么它不识别呢?
完成dart.yml
文件
name: App PlayStore Release
on:
push:
branches: [ master ]
jobs:
version:
name: Create version number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: base64-to-file
id: write_file
uses: timheuer/base64-to-file@v1.0.3
with:
# Name of the file when written to temp location
fileName: 'app_config.json'
# The base64 encoded string
encodedString: ${{ secrets.APP_CONFIG }}
- name: Inject env variables
run: |
mkdir -p ${{ github.workspace }}/config
mv ${{ steps.write_file.outputs.filePath }} ${{ github.workspace }}/config/
- name: Fetch all history for all tags and branches
run: |
git config remote.origin.url https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}
git fetch --prune --depth=10000
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.3
with:
versionSpec: '5.2.x'
- name: Use GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.3
- name: Create version.txt with nuGetVersion
run: echo ${{ steps.gitversion.outputs.nuGetVersion }} > version.txt
- name: Upload version.txt
uses: actions/upload-artifact@v2
with:
name: gitversion
path: version.txt
build:
name: Build APK and Create release
needs: [ version ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get version.txt
uses: actions/download-artifact@v2
with:
name: gitversion
- name: Create new file without newline char from version.txt
run: tr -d '\n' < version.txt > version1.txt
- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt
- name: Update version in YAML
run: sed -i 's/99.99.99+99/${{ steps.version.outputs.content }}+${{ github.run_number }}/g' pubspec.yaml
- name: Update KeyStore password in gradle properties
run: sed -i 's/#{KEYSTORE_PASS}#/${{ secrets.KEYSTORE_PASS }}/g' android/key.properties
- name: Update KeyStore key password in gradle properties
run: sed -i 's/#{KEYSTORE_KEY_PASS}#/${{ secrets.KEYSTORE_KEY_PASS }}/g' android/key.properties
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.17.0'
- run: flutter pub get
- run: flutter test
- run: flutter build apk --release --split-per-abi
- run: flutter build appbundle
- name: Create a Release in GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/app-release.aab"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
- name: Upload app bundle
uses: actions/upload-artifact@v2
with:
name: appbundle
path: build/app/outputs/bundle/release/app-release.aab
release:
name: Release app to internal track
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get appbundle from artifacts
uses: actions/download-artifact@v2
with:
name: appbundle
- name: Release app to internal track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }}
packageName: com.notes.ounotes
releaseFile: app-release.aab
track: internal
whatsNewDirectory: distribution/whatsnew
完成 Pubspec.yaml 文件
name: FSOUNotes
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
# //publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 99.99.99+99
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
shared_preferences: ^0.5.7+3
google_sign_in: ^4.5.1
fluttertoast: ^4.0.1
flutter_mailer: ^0.5.1
open_appstore: ^1.0.2
share: ^0.6.4+3
intl: ^0.16.1
font_awesome_flutter: ^8.8.1
flutter_full_pdf_viewer: ^1.0.6
path_provider: ^1.6.11
cuid: ^0.1.2
shimmer: ^1.1.1
file_picker: ^1.12.0
url_launcher: ^5.4.11
expansion_tile_card: ^1.0.3
flutter_typeahead: ^1.8.1
mime: ^0.9.6+3
awesome_dialog: ^1.1.3
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
stacked: ^1.6.0
stacked_hooks: 0.1.1+3
stacked_services: ^0.4.4+1
logger: ^0.6.0
# http request
http: ^0.12.0+2
# async package to add additional Cancellable operations
async: ^2.0.8
firebase_auth: ^0.16.1
cloud_firestore: ^0.13.7
firebase_storage: ^3.1.6
image_picker: ^0.6.7+2
cached_network_image: ^2.2.0+1
firebase_messaging: ^6.0.16
flutter_auth_buttons: ^0.6.0
auto_route: ^0.5.0
modal_progress_hud: ^0.1.3
permission_handler: ^5.0.1+1
get_it:
injectable:
flutter_hooks:
observable_ish:
dev_dependencies:
flutter_launcher_icons: "^0.7.3"
flutter_test:
sdk: flutter
build_runner:
auto_route_generator:
injectable_generator:
mockito:
flutter_icons:
image_path: "assets/images/apnaicon.png"
android: true
ios: true
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/pdf.png
- assets/images/pdf1.png
- assets/images/link.png
- assets/images/Applogo.jpg
- assets/images/apnaicon.png
- assets/images/1.png
- assets/images/2.png
- assets/images/3.png
- assets/images/4.png
- assets/images/5.png
- assets/images/6.png
- assets/images/7.png
- assets/images/github-logo.png
- assets/images/OU_Logo.jpg
- config/
fonts:
- family: OpenSans
fonts:
- asset: assets/fonts/OpenSans-Regular.ttf
- asset: assets/fonts/OpenSans-Bold.ttf
weight: 700
- family: Quicksand
fonts:
- asset: assets/fonts/Quicksand-Regular.ttf
- asset: assets/fonts/Quicksand-Bold.ttf
weight: 700
- family: Custom
fonts:
- asset: assets/fonts/Custom.ttf
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages