Add env var check for verbose and supporting function #113
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 and Push | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- '*.*.*' | |
pull_request: | |
branches: | |
- 'main' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
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 | |
with: | |
version: latest | |
- | |
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: Set current epoch time as env variable | |
run: echo "NOW=$(date +%s)" >> $GITHUB_ENV | |
- | |
name: Check current date | |
run: echo $NOW | |
- | |
name: Docker meta | |
id: meta | |
uses: crazy-max/[email protected] | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/gateway-discord | |
tags: | | |
type=edge | |
type=ref,event=branch | |
type=ref,event=pr | |
type=sha,prefix=sha-,suffix=-${{env.NOW}},format=short | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.created=${{ steps.meta.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.version=${{ steps.meta.outputs.version }} | |
org.opencontainers.image.licenses=MIT | |
- | |
name: Login to DockerHub | |
uses: docker/[email protected] | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Build and push | |
id: docker_build | |
uses: docker/[email protected] | |
with: | |
context: . | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |