-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (86 loc) · 3.27 KB
/
docker-publish.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Docker
on:
push:
# Publish `main` as Docker `latest` image.
branches: [main, playtest/*]
env:
IMAGE_NAME: edwardcarmack/gearforce-web
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
build:
runs-on: ubuntu-latest
if: github.event_name == 'push'
outputs:
IMAGE_TAGS: ${{ steps.gather-variables.outputs.IMAGE_TAGS }}
SHA: ${{ steps.gather-variables.outputs.SHA }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Gather variables"
id: gather-variables
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
SHA=$(echo "${{ github.sha }}" | cut -c1-7)
echo "SHA=$SHA" >> "$GITHUB_OUTPUT"
IMAGE_TAGS="$IMAGE_NAME:$VERSION,$IMAGE_NAME:$SHA"
echo "IMAGE_TAGS=$IMAGE_TAGS" >> "$GITHUB_OUTPUT"
# Set up Flutter.
- name: Clone Flutter repository with stable channel
uses: subosito/flutter-action@v2
with:
channel: stable
- run: flutter doctor -v
# Checkout code and get packages.
- name: Checkout code
uses: actions/checkout@v4
- run: flutter pub get
# Analyze, check formatting, and run unit tests.
- run: flutter analyze
- name: Ensure the Dart code is formatted correctly
run: dart format --set-exit-if-changed .
- name: Run Flutter unit tests
run: flutter test
- name: Build Flutter web
run: flutter build web --release
- name: "Set up QEMU"
uses: docker/setup-qemu-action@v3
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
- name: "Log into DockerHub"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Build and push"
uses: docker/build-push-action@v5
with:
context: .
push: true
target: release
tags: ${{ steps.gather-variables.outputs.IMAGE_TAGS }}
deploy:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: Kubernetes set context
uses: Azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- name: Deploy latest main to the linode cluster
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
helm upgrade -n gearforce --install --set image.tag=${{ needs.build.outputs.SHA }} --set replicaCount=2 ${{ secrets.HELM_RELEASE_NAME }} chart/gearforce
- name: Deploy to playtest on the linode cluster
if: github.event_name == 'push' && github.ref == 'refs/heads/playtest/nj'
run: |
helm upgrade -n playtest --install --set image.tag=${{ needs.build.outputs.SHA }} --set replicaCount=1 gfpt1 chart/gearforce