Build Active Branches #20954
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Active Branches | |
on: | |
schedule: | |
- cron: "0 * * * *" | |
workflow_dispatch: | |
jobs: | |
fetch-branches: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.fetch-refs.outputs.matrix }} | |
empty_matrix: ${{ steps.check-matrix.outputs.empty_matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
repository: flutter/flutter | |
path: flutter | |
- run: for remote in `git -C flutter branch -r`; do git -C flutter branch --track ${remote#origin/} $remote | true; done | |
- id: fetch-refs | |
run: | | |
matrix=$(git -C flutter for-each-ref --sort=-committerdate refs/heads/ | sed 's/^.*commit.\(.*\)/"\1"/g' | jq -sc 'map(sub("refs/heads/"; "")) | .[:20] | {channel: . , include: map({channel: . , tags: [ if . == "stable" then ., "latest" else . end ]})}') | |
echo "::set-output name=matrix::$matrix" | |
- name: Check matrix | |
id: check-matrix | |
run: | | |
echo "::set-output name=empty_matrix::$(echo '${{ steps.fetch-refs.outputs.matrix }}' | jq '.channel | length > 0 | not')" | |
build-branches: | |
needs: fetch-branches | |
runs-on: ubuntu-latest | |
if: ${{ needs.fetch-branches.outputs.empty_matrix == 'false' }} | |
strategy: | |
matrix: ${{fromJson(needs.fetch-branches.outputs.matrix)}} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup buildx | |
uses: docker/setup-buildx-action@v3.0.0 | |
with: | |
install: true | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3.0.0 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push image | |
run: | | |
docker build \ | |
-t fischerscode/flutter:$(echo ${{ join(matrix.tags, ' | tr + _) -t fischerscode/flutter:$(echo ') }} | tr + _) \ | |
--build-arg=flutterVersion=${{ matrix.channel }} \ | |
--cache-from=type=registry,ref=fischerscode/flutter-cache:$(echo ${{ matrix.channel }} | tr + _) \ | |
--cache-to=type=registry,ref=fischerscode/flutter-cache:$(echo ${{ matrix.channel }} | tr + _),mode=max \ | |
--push \ | |
--platform linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x \ | |
. | |
- name: Build and push sudo image | |
run: | | |
docker build \ | |
-t fischerscode/flutter-sudo:$(echo ${{ join(matrix.tags, ' | tr + _) -t fischerscode/flutter-sudo:$(echo ') }} | tr + _) \ | |
--build-arg=flutterVersion=${{ matrix.channel }} \ | |
--push \ | |
--platform linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x \ | |
-f Dockerfile.sudo \ | |
. |