From 15e95bee3f03304f583f82b0ae2d4e8377e1d53a Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Thu, 8 Apr 2021 14:38:16 -0700 Subject: [PATCH] Automate building and pushing of docker container This workflow file will automatically build a container and push it to ghcr.io and dockerhub. You'll need to generate a Personal Access Token with the permissions needed to publish packages. You'll also need to create a dockerhub account. You will add the Personal Access Token (CR_PAT), DOCKERHUB_USERNAME, and DOCKERHUB_PASSWORD secrets. Please let me know if you have any trouble with this. --- .github/workflows/build.yml | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2f20ff4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,59 @@ +name: Build Master + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Get current time + uses: 1466587594/get-current-time@v2 + id: current-time + with: + format: YYYY-MM-DD--HH + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + platforms: linux/amd64,linux/arm64,linux/arm + push: true + tags: | + sonicnkt/glauth-ui:latest + sonicnkt/glauth-ui + ghcr.io/sonicnkt/glauth-ui:latest + ghcr.io/sonicnkt/glauth-ui + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache