Docker build image #8025
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker build image | |
on: | |
schedule: | |
- cron: "0 * * * *" | |
push: | |
branches: | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get latest release | |
id: release | |
uses: pozetroninc/github-action-get-latest-release@master | |
with: | |
repository: trs/shift-code | |
excludes: prerelease, draft | |
- uses: actions/cache@v2 | |
id: cache | |
with: | |
path: release | |
key: ${{ runner.os }}-v11-${{ steps.release.outputs.release }} | |
- name: Set VERSION | |
if: steps.cache.outputs.cache-hit != 'true' | |
id: vars | |
run: echo ::set-output name=VERSION::$(echo ${{ steps.release.outputs.release }} | sed 's/^v//') | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
platforms: all | |
- name: Check Out Repo | |
uses: actions/checkout@v2 | |
- name: Login to GHCR | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GHCR_USERNAME }} | |
password: ${{ secrets.GHCR_PASSWORD }} | |
- name: Set up Docker Buildx | |
if: steps.cache.outputs.cache-hit != 'true' | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
version: latest | |
- name: Set up build timestamp | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: echo "timestamp=$(date +%Y%m%d)" >> $GITHUB_ENV | |
- name: Build and push docker image | |
if: steps.cache.outputs.cache-hit != 'true' | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 | |
push: true | |
tags: ghcr.io/sharkusmanch/shift-code:latest, ghcr.io/sharkusmanch/shift-code:${{ steps.vars.outputs.VERSION }} | |
build-args: VERSION=${{ steps.vars.outputs.VERSION }} |