Skip to content

Commit

Permalink
Use separate job for extracting version
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Mar 20, 2024
1 parent 2acc3ad commit 49d4cbe
Showing 1 changed file with 36 additions and 27 deletions.
63 changes: 36 additions & 27 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,8 @@ env:
REGISTRY_IMAGE: openproject/community

jobs:
build:
if: github.repository == 'opf/openproject'
runs-on: runs-on,runner=8cpu-linux,family=m7i+m7a,run-id=${{ github.run_id }}
strategy:
matrix:
include:
- platform: linux/amd64
target: slim
- platform: linux/arm64/v8
target: slim
- platform: linux/amd64
target: all-in-one
- platform: linux/ppc64le
bim_support: false
target: all-in-one
- platform: linux/arm64/v8
bim_support: false
target: all-in-one
extract_version:
runs-on: ubuntu-latest
steps:
- name: Extract version
id: extract_version
Expand All @@ -56,19 +40,43 @@ jobs:
echo "Unsupported event"
exit 1
fi
if [ -z "$TAG_REF" ] || [ -z "$CHECKOUT_REF" ]; then
echo "No TAG_REF or CHECKOUT_REF set. Aborting"
exit 1
fi
VERSION=${TAG_REF#v}
echo "Version: $VERSION"
echo "::set-output name=version::$VERSION"
echo "::set-output name=checkout_ref::$CHECKOUT_REF"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "checkout_ref=$CHECKOUT_REF" >> "$GITHUB_OUTPUT"
outputs:
version: ${{ steps.extract_version.outputs.version }}
checkout_ref: ${{ steps.extract_version.outputs.checkout_ref }}
build:
needs:
- extract_version
if: github.repository == 'opf/openproject'
runs-on: runs-on,runner=8cpu-linux,family=m7i+m7a,run-id=${{ github.run_id }}
strategy:
matrix:
include:
- platform: linux/amd64
target: slim
- platform: linux/arm64/v8
target: slim
- platform: linux/amd64
target: all-in-one
- platform: linux/ppc64le
bim_support: false
target: all-in-one
- platform: linux/arm64/v8
bim_support: false
target: all-in-one
steps:
- name: Checkout
with:
ref: ${{ steps.extract_version.outputs.checkout_ref }}
ref: ${{ needs.extract_version.outputs.checkout_ref }}
uses: actions/checkout@v4
- name: Prepare docker files
run: |
Expand All @@ -88,7 +96,7 @@ jobs:
uses: docker/metadata-action@v4
with:
tags: |
type=semver,pattern={{version}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern={{version}},value=${{ needs.extract_version.outputs.version }}
images: |
${{ env.REGISTRY_IMAGE }}
- name: Build image
Expand Down Expand Up @@ -150,6 +158,7 @@ jobs:
matrix:
target: [slim, all-in-one]
needs:
- extract_version
- build
steps:
- name: Download digests
Expand Down Expand Up @@ -178,9 +187,9 @@ jobs:
latest=false
suffix=${{ steps.set_suffix.outputs.suffix }}
tags: |
type=semver,pattern={{version}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern={{major}},value=${{ steps.extract_version.outputs.version }}
type=semver,pattern={{version}},value=${{ needs.extract_version.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.extract_version.outputs.version }}
type=semver,pattern={{major}},value=${{ needs.extract_version.outputs.version }}
type=raw,value=dev,priority=200,enable={{is_default_branch}}
- name: Login to Docker Hub
uses: docker/login-action@v2
Expand Down

0 comments on commit 49d4cbe

Please sign in to comment.