mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-28 11:41:46 +03:00
87 lines
2.7 KiB
YAML
87 lines
2.7 KiB
YAML
name: CI
|
|
|
|
env:
|
|
DEFAULT_DOCKER_IMAGE: nicolargo/glances
|
|
NODE_ENV: ${{ (contains('refs/heads/master', github.ref) || startsWith(github.ref, 'refs/tags/v')) && 'prod' || 'dev' }}
|
|
DOCKER_PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64,linux/386
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ develop ]
|
|
push:
|
|
branches: [ master, develop ]
|
|
tags:
|
|
- v*
|
|
|
|
jobs:
|
|
buildx:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ env.NODE_ENV }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-${{ env.NODE_ENV }}
|
|
|
|
- name: Configure ENVs
|
|
env:
|
|
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE || env.DEFAULT_DOCKER_IMAGE }}
|
|
DOCKERFILE: ${{ env.NODE_ENV == 'prod' && './docker-files/Dockerfile' || './docker-files/dev.Dockerfile' }}
|
|
PUSH_IMAGE: ${{ env.NODE_ENV == 'prod' && 'true' || 'false' }}
|
|
run: |
|
|
ls -la /tmp/.buildx-cache || true
|
|
VERSION=latest
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
|
fi
|
|
|
|
if [[ $GITHUB_REF == refs/heads/develop ]]; then
|
|
VERSION=dev
|
|
fi
|
|
|
|
echo "DOCKERFILE=${DOCKERFILE}" >> $GITHUB_ENV
|
|
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
|
echo "PUSH_IMAGE=${PUSH_IMAGE}" >> $GITHUB_ENV
|
|
echo "TAGS=${DOCKER_IMAGE}:${VERSION}" >> $GITHUB_ENV
|
|
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
|
|
echo "VCS_REF=${GITHUB_SHA::8}" >> $GITHUB_ENV
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
with:
|
|
platforms: all
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
with:
|
|
version: latest
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
if: ${{env.PUSH_IMAGE == 'true'}}
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: ${{env.PUSH_IMAGE == 'true'}}
|
|
tags: ${{env.TAGS}}
|
|
build-args: |
|
|
VERSION=${{env.VERSION}}
|
|
BUILD_DATE=${{env.BUILD_DATE}}
|
|
VCS_REF=${{env.VCS_REF}}
|
|
context: .
|
|
file: ${{env.DOCKERFILE}}
|
|
platforms: ${{env.DOCKER_PLATFORMS}}
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|