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@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.8' - name: Install cosign if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@main - name: Setup Docker buildx uses: docker/setup-buildx-action@v1 - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' uses: docker/login-action@v1 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@v2 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 }} - name: Sign the published Docker image if: ${{ github.event_name != 'pull_request' && !github.event.repository.private }} env: COSIGN_EXPERIMENTAL: "true" run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }} - 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)