From 5e8fb292995959586e54f7d8f30015565106b341 Mon Sep 17 00:00:00 2001 From: Mayank Date: Mon, 1 Jun 2020 07:26:18 +0530 Subject: [PATCH] PR Action --- .github/workflows/on-pr.yml | 47 ++++++++++++++++++++++++++++++++++++ .github/workflows/on-tag.yml | 30 +++++++++++------------ README.md | 2 +- 3 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/on-pr.yml diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml new file mode 100644 index 0000000..92e7c2b --- /dev/null +++ b/.github/workflows/on-pr.yml @@ -0,0 +1,47 @@ +name: Docker build on PR +env: + DOCKER_CLI_EXPERIMENTAL: enabled + +on: + pull_request: + branches: + - master + types: [assigned, opened, synchronize, reopened, edited] + +jobs: + build: + runs-on: ubuntu-18.04 + name: Build and push dashboard image + steps: + - name: Set env variables + run: echo ::set-env name=PR_NUMBER::$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + - name: Show set env variables + run: | + printf " PR_NUMBER: %s\n" "$PR_NUMBER" + - name: Login to Docker Hub + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + - name: Checkout project + uses: actions/checkout@v2 + - name: Setup Docker buildx action + uses: crazy-max/ghaction-docker-buildx@v1 + id: buildx + with: + buildx-version: latest + qemu-version: latest + - name: Show available buildx platforms + run: echo ${{ steps.buildx.outputs.platforms }} + - name: Run Docker buildx against tag + run: | + docker buildx build \ + --platform linux/amd64,linux/arm/v7 \ + -t ${{ secrets.DOCKER_HUB_USER }}/dashboard:pr-$PR_NUMBER \ + --output "type=registry" \ + . + - name: Run Docker buildx against stage + run: | + docker buildx build \ + --platform linux/amd64 \ + -f ./Dockerfile.stage \ + -t ${{ secrets.DOCKER_HUB_USER }}/dashboard:pr-$PR_NUMBER \ + --output "type=registry" \ + . \ No newline at end of file diff --git a/.github/workflows/on-tag.yml b/.github/workflows/on-tag.yml index 7e32fcc..6945fcd 100644 --- a/.github/workflows/on-tag.yml +++ b/.github/workflows/on-tag.yml @@ -1,4 +1,4 @@ -name: Automatically Build image on tag +name: Docker build on tag env: DOCKER_CLI_EXPERIMENTAL: enabled @@ -11,44 +11,44 @@ on: jobs: build: runs-on: ubuntu-18.04 - name: Build / Push Umbrel Dashboard on version tag + name: Build and push dashboard image steps: - - name: Setup Environment + - name: Set env variables run: echo ::set-env name=TAG::${GITHUB_REF/refs\/tags\//} - - name: Show set environment variables + - name: Show set env variables run: | printf " TAG: %s\n" "$TAG" - - name: Login to Docker for building + - name: Login to Docker Hub run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Checkout project uses: actions/checkout@v2 - - name: Setup Docker buildx Action + - name: Setup Docker buildx action uses: crazy-max/ghaction-docker-buildx@v1 id: buildx with: buildx-version: latest qemu-version: latest - - name: Available platforms + - name: Show available buildx platforms run: echo ${{ steps.buildx.outputs.platforms }} - - name: Run Docker build X (against tag) + - name: Run Docker buildx against tag run: | docker buildx build \ - --platform linux/amd64,linux/arm/v7,linux/arm64 \ - -t getumbrel/dashboard:$TAG \ + --platform linux/amd64,linux/arm/v7 \ + -t ${{ secrets.DOCKER_HUB_USER }}/dashboard:$TAG \ --output "type=registry" \ . - - name: Run Docker build X (against latest) + - name: Run Docker buildx against latest run: | docker buildx build \ - --platform linux/amd64,linux/arm/v7,linux/arm64 \ - -t getumbrel/dashboard:latest \ + --platform linux/amd64,linux/arm/v7 \ + -t ${{ secrets.DOCKER_HUB_USER }}/dashboard:latest \ --output "type=registry" \ . - - name: Run Docker buildx (against stage) + - name: Run Docker buildx against stage run: | docker buildx build \ --platform linux/amd64 \ -f ./Dockerfile.stage \ - -t getumbrel/dashboard:stage \ + -t ${{ secrets.DOCKER_HUB_USER }}/dashboard:stage \ --output "type=registry" \ . \ No newline at end of file diff --git a/README.md b/README.md index ab77589..bf3ba2f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Umbrel Dashboard](https://static.getumbrel.com/github/github-banner-umbrel-dashboard.svg)](https://github.com/getumbrel/umbrel-dashboard) [![Version](https://img.shields.io/github/v/release/getumbrel/umbrel-dashboard?color=%235351FB&label=version)](https://github.com/getumbrel/umbrel-dashboard/releases) -[![Docker Build](https://img.shields.io/github/workflow/status/getumbrel/umbrel-dashboard/Automatically%20Build%20image%20on%20tag?color=%235351FB)](https://github.com/getumbrel/umbrel-dashboard/actions?query=workflow%3A"Automatically+Build+image+on+tag") +[![Docker Build](https://img.shields.io/github/workflow/status/getumbrel/umbrel-dashboard/Docker%20build%20on%20tag?color=%235351FB)](https://github.com/getumbrel/umbrel-dashboard/actions?query=workflow%3A"Docker+build+on+tag") [![Docker Pulls](https://img.shields.io/docker/pulls/getumbrel/dashboard?color=%235351FB)](https://hub.docker.com/repository/registry-1.docker.io/getumbrel/dashboard/tags?page=1) [![Chat](https://img.shields.io/badge/chat%20on-telegram-%235351FB)](https://t.me/getumbrel)