1
mirror of https://github.com/jakejarvis/docker-tor.git synced 2025-04-26 01:55:22 -04:00
docker-tor/.github/workflows/build-and-push.yml
2022-12-29 11:54:34 -05:00

58 lines
1.5 KiB
YAML

name: Build and push image
on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- '*'
pull_request:
branches:
- 'main'
permissions:
contents: read
packages: write
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v4
id: meta
with:
images: |
jakejarvis/tor
ghcr.io/jakejarvis/tor
flavor: |
latest=auto
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=pep440,pattern={{raw}}
type=pep440,pattern=v{{major}}.{{minor}}
type=ref,event=pr
- uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max