-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (68 loc) · 2.7 KB
/
build-stable.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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 }}
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')
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
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, $BUILD_TAG"
docker build \
-t "$DOCKER_REPO":latest -t "$DOCKER_REPO:$BUILD_TAG" \
--push \
--platform linux/amd64 \
.