Skip to content

Instantly share code, notes, and snippets.

@craftslab
Last active February 8, 2024 13:03
Show Gist options
  • Save craftslab/fb38b7a62ec6e7d35a8a829d871e7834 to your computer and use it in GitHub Desktop.
Save craftslab/fb38b7a62ec6e7d35a8a829d871e7834 to your computer and use it in GitHub Desktop.
github actions

GitHub Actions

Actions

---
name: Release

on:
  push:
    branches: [ main ]
    tags:
      - v*

jobs:
  release:
    name: Released on ${{matrix.os}}
    runs-on: ${{matrix.os}}
    strategy:
      matrix:
        os: [ ubuntu-20.04 ]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 1
      - name: Caching
        uses: actions/cache@v4
        with:
          path: "~/.cache/bazel"
          key: ${{matrix.os}}-bazel
      - name: Install
        run: make install
      - name: Build
        run: make build
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: bazel-buildfarm-artifact
          path: |
            bazel-bin/src/main/java/build/buildfarm/*_deploy.jar
            bazel-bin/src/main/java/build/buildfarm/tools/*_deploy.jar
  push:
    name: Pushed on ${{matrix.os}}
    needs: [ release ]
    runs-on: ${{matrix.os}}
    strategy:
      matrix:
        os: [ ubuntu-20.04 ]
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: bazel-buildfarm-artifact
      - name: Push
        run: |
          git clone https://gitee.com/distbuild/bazel-buildfarm-release.git
          git config --global user.name "craftslab"
          git config --global user.email "angersax@sina.com"
          cp -r *.jar tools/*.jar -t bazel-buildfarm-release
          pushd bazel-buildfarm-release || exit 1
          git add .
          git commit -m "feat[gh]: updated from https://github.com/${{github.repository}}/commit/${{github.sha}}"
          git push https://craftslab:${{ secrets.GITEE_DISTBUILD_TOKEN }}@gitee.com/distbuild/bazel-buildfarm-release.git --all
          popd || exit 1

See distbuild-bazel-buildfarm-actions

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment