You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.7 KiB
95 lines
2.7 KiB
name: Docker
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
- 'develop'
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
jobs:
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
id-token: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Setup Docker buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log into registry ${{ env.REGISTRY }}
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Get date as semver
|
|
id: calver
|
|
env:
|
|
REF_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
python -c "
|
|
from datetime import datetime, timedelta
|
|
from os import environ
|
|
ref = environ['REF_NAME']
|
|
now = datetime.now()
|
|
date = now.strftime('%y.%m.%d')
|
|
delta = timedelta(hours=now.hour,minutes=now.minute,seconds=now.second)
|
|
print(f'::set-output name=current::{date}-{ref}.{delta.seconds}')
|
|
"
|
|
|
|
- name: Extract Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v3
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=raw,value=${{ steps.calver.outputs.current }}
|
|
type=raw,value=${{ github.ref_name }}
|
|
type=sha
|
|
|
|
- name: Build and push Docker image
|
|
id: build-and-push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
build-args: |
|
|
APP_VERSION=${{ steps.calver.outputs.current }}
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
- name: Trigger release job
|
|
if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' && !github.event.repository.private }}
|
|
uses: toptal/jenkins-job-trigger-action@master
|
|
with:
|
|
jenkins_url: ${{ secrets.JENKINS_URL }}
|
|
jenkins_user: ${{ secrets.JENKINS_USER }}
|
|
jenkins_token: ${{ secrets.JENKINS_TOKEN }}
|
|
job_name: "nikita-tokarch-uk/job/make-a-release"
|
|
job_params: |
|
|
{
|
|
"VERSION": "${{ steps.calver.outputs.current }}"
|
|
}
|
|
job_timeout: "300" # Default 30 sec. (optional)
|
|
|