Skip to content

Commit

Permalink
chore(ci): extract version from dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm committed Nov 8, 2023
1 parent ed8b3f1 commit ccf9b74
Showing 1 changed file with 13 additions and 37 deletions.
50 changes: 13 additions & 37 deletions .github/workflows/publish-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,69 +28,36 @@ jobs:
include:
- name: traefik
path: traefik
version:
short: 1
full: 1.7.34-alpine

- name: alpine
path: alpine
version:
short: 3
full: 3.17

- name: php
path: php/7.4-apache
version:
short: 7-apache
full: 7.4-apache

- name: php
path: php/7.4-fpm
version:
short: 7
full: 7.4

- name: php
path: php/8.2-fpm
version:
short: 8
full: 8.2

- name: adminer
path: adminer
version:
short: 4
full: 4.8-3.24.4

- name: mariadb
path: mariadb
version:
short: 10
full: 10.9-3.26.4

- name: nocodb
path: nocodb
version:
short: 0.202
full: 0.202.5

- name: wordpress
path: wordpress/php7.4
version:
short: 6-php7
full: 6.1-php7.4-fpm

- name: wordpress
path: wordpress/php8.2
version:
short: 6
full: 6.3-php8.2-fpm

- name: tdlib
path: tdlib
version:
short: 1
full: 1.8.0

permissions:
contents: read
Expand Down Expand Up @@ -132,6 +99,15 @@ jobs:
username: ${{github.repository_owner}}
password: ${{secrets.GITHUB_TOKEN}}

- name: 🏗 Extract version from dockerfile
if: ${{ steps.file_change.outputs.container_folder == 'true' }}
id: meta
run: |
ref_name=$(grep 'org.opencontainers.image.ref.name' ./${{ matrix.path }}/Dockerfile | cut -d'"' -f2)
version=$(grep 'org.opencontainers.image.version' ./${{ matrix.path }}/Dockerfile | cut -d'"' -f2)
echo ::set-output name=ref_name::${ref_name}
echo ::set-output name=version::${version}
- name: 🚀 Build and push container image
if: ${{ steps.file_change.outputs.container_folder == 'true' }}
id: build_and_push
Expand All @@ -140,8 +116,8 @@ jobs:
context: ./${{matrix.path}}
push: ${{github.event_name != 'pull_request'}}
tags: |
${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{matrix.version.short}}
${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{matrix.version.full}}
${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{steps.meta.outputs.ref_name}}
${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{steps.meta.outputs.version}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
Expand All @@ -153,5 +129,5 @@ jobs:
env:
COSIGN_EXPERIMENTAL: 'true'
run: |
cosign sign --yes "${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{matrix.version.short}}@${{steps.build_and_push.outputs.digest}}"
cosign sign --yes "${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{matrix.version.full}}@${{steps.build_and_push.outputs.digest}}"
cosign sign --yes "${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{steps.meta.outputs.ref_name}}@${{steps.build_and_push.outputs.digest}}"
cosign sign --yes "${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{steps.meta.outputs.version}}@${{steps.build_and_push.outputs.digest}}"

0 comments on commit ccf9b74

Please sign in to comment.