如何在 Forgejo 中创建多行文本文件(使用 Github Actions 语法)?

问题描述 投票:0回答:1

我正在尝试在 Forgejo 实例(即 Gitea fork)上设置运行器,它使用 Github Actions 语法。 我有以下 yaml 文件:

name: Android CI

on: [push]

jobs:
  build:
    runs-on: high
    steps:
      - run: mkdir ~/.gradle/
      - run: echo "systemProp.http.proxyHost=proxy.domain.com" > ~/.gradle/gradle.properties
      - run: echo "systemProp.https.proxyHost=proxy.domain.com" >> ~/.gradle/gradle.properties
      - run: echo "systemProp.http.proxyPort=9999" >> ~/.gradle/gradle.properties
      - run: echo "systemProp.https.proxyPort=9999" >> ~/.gradle/gradle.properties
      - run:  cat ~/.gradle/gradle.properties
      - name: Checkout
        uses: https://github.com/actions/checkout@v4
      - name: set up JDK 1.8
        uses: https://github.com/actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Build with Gradle
        run: ./gradlew assembleDebug

它可以工作,但看起来很粗糙。我对 Github Action 语法的了解可能太少,无法在 1 个命令中创建和填充 gradle.properties。 请建议如何正确执行此操作。

尝试执行在 GitHub 操作中创建文件

中的操作
yaml continuous-integration github-actions
1个回答
0
投票

正确方法之一:

name: Android CI on Push
run-name: On Push Android CI by @${{ github.actor }}

on: [push,fork]

# manually run from the Actions tab
workflow_dispatch: 

env:
  https_proxy: secureproxy.internal:9999
  http_proxy: secureproxy.internal:9999
  use_proxy: yes
  no_proxy: localhost,*.org,*.net,*.com,*.io,*.google

jobs:
  build:
    runs-on: high
    steps:
      
      - name: set up JDK 
        uses: https://github.com/actions/setup-java@v4
        with:
          distribution: 'temurin' # See 'Supported distributions' for available options
          java-version: '17'

      - name: Prepare android sdk...
        run: |
          $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0" "extras;android;m2repository" 

      
      - name: Install HTTP Toolkit's intercept CA
        run: |
          wget -S https://amiusing.httptoolkit.tech/certificate --no-check-certificate -O ~/intercept_ca.crt

          sudo apt-get install -y ca-certificates
          sudo cp ~/*.crt /usr/local/share/ca-certificates
          sudo update-ca-certificates          
          echo Import certficate to local jdk at $JAVA_HOME
          sudo keytool -delete -trustcacerts -cacerts -storepass changeit -noprompt -alias intercept_ca || true
          sudo keytool -import -trustcacerts -cacerts -storepass changeit -noprompt -alias intercept_ca -file ~/intercept_ca.crt
        

      - name: Prepare system-wide gradle.properties
        run: |
          mkdir ~/.gradle/
          cat <<EOF > ~/.gradle/gradle.properties
          systemProp.gradle.wrapperUser=TO_BE_FILLEDNOSUCHUSER_GP_GIT@corp.internal
          systemProp.gradle.wrapperPassword=TO_BE_FILLED
          systemProp.http.proxyHost=secureproxy.internal
          systemProp.https.proxyHost=secureproxy.internal
          systemProp.http.proxyPort=9999
          systemProp.https.proxyPort=9999

      - name: Validating system-wide gradle.properties
        run:  cat ~/.gradle/gradle.properties

      - name: Checkout
        uses: https://github.com/actions/checkout@v4

      - name: Build with Gradle
        run: |          

          echo Building...
          ./gradlew assembleDebug  --no-daemon

制表符和空格极其重要

© www.soinside.com 2019 - 2024. All rights reserved.