Build Flutter Stable #60
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 Flutter Stable | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
env: | |
DOCKER_REPO: "chiragji/flutter-aio" | |
jobs: | |
get-flutter-version: | |
name: Get Latest Flutter Version | |
runs-on: ubuntu-latest | |
outputs: | |
flutter_version: ${{ steps.get-version.outputs.flutter_version }} | |
steps: | |
- name: Get the latest Flutter version | |
id: get-version | |
run: | | |
latest_version=$(curl -s https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json \ | |
| jq -r '.releases[] | select(.channel=="stable") | .version' | head -n 1) | |
echo "Latest Flutter version is $latest_version" | |
echo "flutter_version=$latest_version" >> $GITHUB_OUTPUT | |
check-docker-tags: | |
name: Check Docker Image Tags | |
runs-on: ubuntu-latest | |
needs: get-flutter-version | |
outputs: | |
version_exists: ${{ steps.check-existence.outputs.version_exists }} | |
build_tag: ${{ steps.check-existence.outputs.build_tag }} | |
steps: | |
- name: Fetch existing Docker image tags | |
id: get-tags | |
run: | | |
tags=$(curl -s "https://registry.hub.docker.com/v2/repositories/$DOCKER_REPO/tags?page_size=100" | jq -r '.results[].name' | paste -sd "," -) | |
echo "Docker tags: $tags" | |
echo "tags=$tags" >> $GITHUB_OUTPUT | |
- name: Check if Flutter version exists in Docker tags | |
id: check-existence | |
run: | | |
if echo "${{ steps.get-tags.outputs.tags }}" | grep -q "${{ needs.get-flutter-version.outputs.flutter_version }}"; then | |
echo "Flutter version ${{ needs.get-flutter-version.outputs.flutter_version }} already exists as a Docker tag." | |
echo "version_exists=true" >> $GITHUB_OUTPUT | |
else | |
echo "Flutter version ${{ needs.get-flutter-version.outputs.flutter_version }} does not exist as a Docker tag." | |
echo "version_exists=false" >> $GITHUB_OUTPUT | |
echo "build_tag=${{ needs.get-flutter-version.outputs.flutter_version }}" >> $GITHUB_OUTPUT | |
echo "will build tag ${{ needs.get-flutter-version.outputs.flutter_version }}" | |
fi | |
build-stable: | |
runs-on: ubuntu-latest | |
needs: check-docker-tags | |
if: needs.check-docker-tags.outputs.version_exists == 'false' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup buildx | |
uses: docker/setup-buildx-action@v3.7.1 | |
with: | |
install: true | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3.3.0 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push image | |
run: | | |
echo "Starting building tags latest, ${{ needs.check-docker-tags.outputs.build_tag }}" | |
docker build \ | |
-t "$DOCKER_REPO":latest -t "$DOCKER_REPO:${{ needs.check-docker-tags.outputs.build_tag }}" \ | |
--push \ | |
--platform linux/amd64 \ | |
. |