You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.9 KiB
YAML
85 lines
2.9 KiB
YAML
name: docker-pr
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [master]
|
|
workflow_dispatch:
|
|
inputs:
|
|
push_image:
|
|
description: 'Push image to registry'
|
|
required: true
|
|
default: 'false'
|
|
type: choice
|
|
options:
|
|
- 'true'
|
|
- 'false'
|
|
image_tag:
|
|
description: 'Docker image tag (e.g., test, pr-13)'
|
|
required: true
|
|
default: 'test'
|
|
type: string
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout code
|
|
uses: actions/checkout@v6
|
|
- name: Set hash
|
|
id: vars
|
|
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
|
- name: Get current date
|
|
id: date
|
|
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
|
|
- name: create-json
|
|
id: create-json
|
|
uses: jsdaniell/create-json@v1.2.3
|
|
with:
|
|
name: "version.json"
|
|
json: '{"type": "docker", "tag": "nightly", "commit": "${{ steps.vars.outputs.sha_short }}", "date": "${{ steps.date.outputs.date }}"}'
|
|
dir: 'backend/'
|
|
- name: setup platform emulator
|
|
uses: docker/setup-qemu-action@v4
|
|
- name: setup multi-arch docker build
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Login to DockerHub
|
|
if: github.event.inputs.push_image == 'true'
|
|
uses: docker/login-action@v4
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to GitHub Container Registry
|
|
if: github.event.inputs.push_image == 'true'
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set push and tag values
|
|
id: build_params
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "push=${{ github.event.inputs.push_image }}" >> $GITHUB_OUTPUT
|
|
if [ "${{ github.event.inputs.push_image }}" = "true" ]; then
|
|
echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/youtubedl-material:${{ github.event.inputs.image_tag }},ghcr.io/${{ github.repository_owner }}/youtubedl-material:${{ github.event.inputs.image_tag }}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tags=youtubedl-material:${{ github.event.inputs.image_tag }}" >> $GITHUB_OUTPUT
|
|
fi
|
|
else
|
|
echo "push=false" >> $GITHUB_OUTPUT
|
|
echo "tags=youtubedl-material:nightly-pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: build & push images
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64/v8
|
|
#platforms: linux/amd64
|
|
push: ${{ steps.build_params.outputs.push }}
|
|
tags: ${{ steps.build_params.outputs.tags }}
|