Skip to content

Commit

Permalink
Improved CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
shajen committed Feb 2, 2024
1 parent 7fb925e commit 991cc55
Showing 1 changed file with 47 additions and 23 deletions.
70 changes: 47 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,56 @@
name: main
on: push

on:
push:
env:
IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }}

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Set up docker cache
uses: actions/cache@v3
with:
path: /var/lib/docker
key: ${{ runner.os }}-docker
- name: Checkout
uses: actions/checkout@v3
- name: Build monitor
run: docker build -t monitor .
- name: Deploy monitor branch
if: ${{ github.ref_type == 'branch' && github.ref_name == vars.CI_BRANCH && github.event_name != 'pull_request' }}
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ env.IMAGE }}:test
cache-from: |
type=registry,ref=${{ env.IMAGE }}:latest
type=registry,ref=${{ env.IMAGE }}:${{ github.ref_name }}
- name: Test
run: |
TAG=${GITHUB_REF_NAME}
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} docker.io
docker buildx create --use || true
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t docker.io/shajen/monitor:$TAG --push .
- name: Deploy monitor tag
docker run --rm ${{ env.IMAGE }}:test python3 manage.py test
- name: Push development version
if: ${{ github.ref_type == 'branch' && github.ref_name == vars.CI_BRANCH }}
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64
tags: ${{ env.IMAGE }}:${{ github.ref_name }}
cache-from: type=registry,ref=${{ env.IMAGE }}:${{ github.ref_name }}
cache-to: type=inline
- name: Push release version
if: ${{ github.ref_type == 'tag' }}
run: |
TAG=${GITHUB_REF_NAME/v/}
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} docker.io
docker buildx create --use || true
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t docker.io/shajen/monitor:$TAG -t docker.io/shajen/monitor --push .
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ github.ref_name }}
cache-from: |
type=registry,ref=${{ env.IMAGE }}:latest
type=registry,ref=${{ env.IMAGE }}:${{ github.ref_name }}
cache-to: type=inline

0 comments on commit 991cc55

Please sign in to comment.