Skip to content

Merge pull request #377 from Ariemeth/fix_spaces_and_precise #614

Merge pull request #377 from Ariemeth/fix_spaces_and_precise

Merge pull request #377 from Ariemeth/fix_spaces_and_precise #614

name: Docker
on:
push:
# Publish `main` as Docker `latest` image.
branches: [main]
# Publish `v1.2.3` tags as releases.
tags: [v*]
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'
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
IMAGE_TAGS="$IMAGE_NAME:$VERSION,$IMAGE_NAME:${{ github.sha }}"
echo "::set-output name=IMAGE_TAGS::$IMAGE_TAGS"
# 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@v1
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v1
- name: "Log into DockerHub"
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Build and push"
uses: docker/build-push-action@v2
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@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- name: Deploy to linode cluster
run: |
helm upgrade -n gearforce --install --set image.tag=${{ github.sha }} --set replicaCount=2 ${{ secrets.HELM_RELEASE_NAME }} chart/gearforce