Action: Limit ghcr push to luigi311 #350
Workflow file for this run
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: CI | |
on: | |
push: | |
paths-ignore: | |
- .gitignore | |
- "*.md" | |
pull_request: | |
paths-ignore: | |
- .gitignore | |
- "*.md" | |
jobs: | |
pytest: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: "Install dependencies" | |
run: pip install -r requirements.txt && pip install -r test/requirements.txt | |
- name: "Run tests" | |
run: pytest -vvv | |
docker: | |
runs-on: ubuntu-latest | |
needs: pytest | |
env: | |
DEFAULT_VARIANT: alpine | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dockerfile: Dockerfile.alpine | |
variant: alpine | |
- dockerfile: Dockerfile.slim | |
variant: slim | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ secrets.DOCKER_USERNAME }}/jellyplex-watched,enable=${{ secrets.DOCKER_USERNAME != '' }} | |
# Do not push to ghcr.io on PRs due to permission issues, only push if the owner is luigi311 so it doesnt fail on forks | |
ghcr.io/${{ github.repository }},enable=${{ github.event_name != 'pull_request' && github.repository_owner == 'luigi311'}} | |
tags: | | |
type=raw,value=latest,enable=${{ matrix.variant == env.DEFAULT_VARIANT && github.ref_name == github.event.repository.default_branch }} | |
type=raw,value=dev,enable=${{ matrix.variant == env.DEFAULT_VARIANT && github.ref_name == 'dev' }} | |
type=raw,value=latest,suffix=-${{ matrix.variant }},enable={{ is_default_branch }} | |
type=ref,event=branch,suffix=-${{ matrix.variant }} | |
type=ref,event=branch,enable=${{ matrix.variant == env.DEFAULT_VARIANT }} | |
type=ref,event=pr,suffix=-${{ matrix.variant }} | |
type=ref,event=pr,enable=${{ matrix.variant == env.DEFAULT_VARIANT }} | |
type=semver,pattern={{ version }},suffix=-${{ matrix.variant }} | |
type=semver,pattern={{ version }},enable=${{ matrix.variant == env.DEFAULT_VARIANT }} | |
type=semver,pattern={{ major }}.{{ minor }},suffix=-${{ matrix.variant }} | |
type=semver,pattern={{ major }}.{{ minor }},enable=${{ matrix.variant == env.DEFAULT_VARIANT }} | |
type=sha,suffix=-${{ matrix.variant }} | |
type=sha,enable=${{ matrix.variant == env.DEFAULT_VARIANT }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
if: "${{ env.DOCKER_USERNAME != '' }}" | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Login to GitHub Container Registry | |
if: "${{ steps.docker_meta.outcome == 'success' }}" | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build | |
id: build | |
if: "${{ steps.docker_meta.outputs.tags == '' }}" | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ${{ matrix.dockerfile }} | |
platforms: linux/amd64,linux/arm64 | |
push: false | |
tags: jellyplex-watched:action | |
- name: Build Push | |
id: build_push | |
if: "${{ steps.docker_meta.outputs.tags != '' }}" | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ${{ matrix.dockerfile }} | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
# Echo digest so users can validate their image | |
- name: Image digest | |
if: "${{ steps.docker_meta.outcome == 'success' }}" | |
run: echo "${{ steps.build_push.outputs.digest }}" |