Skip to content

Commit

Permalink
SWF: Enhance docker builds using reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
hbenali committed Nov 27, 2024
1 parent 9bc3e57 commit f7da92a
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@ on:
push:
tags:
- '[6-9].[0-9].[0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9]'
env:
DOCKERHUB_IMAGE_NAME: 'exoplatform/exo'

jobs:
build-and-push-image:
parse-docker-build-env:
name: 'Parse Docker Build Environment'
runs-on: ubuntu-latest

outputs:
buildTags: ${{ steps.detect-push-event.outputs.buildTags }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKERHUB_IMAGE_NAME }}

- name: Build and push Docker image to Dockerhub
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Check if push is a tag or branch
id: detect-push-event
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "This is a tag push (${GITHUB_REF#refs/tags/})"
echo "Building docker tag: ${GITHUB_REF#refs/tags/}"
echo "buildTags=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "Unknown push type"
exit 1
fi
build-dockerhub-image:
permissions:
contents: read
packages: write
name: "Build Docker Images to DockerHub Registry"
uses: exoplatform/swf-scripts/.github/workflows/buildDockerImage.yml@master
needs: parse-docker-build-env
with:
dockerImage: "exoplatform/exo"
dockerImageTag: ${{ needs.parse-docker-build-env.outputs.buildTags }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

0 comments on commit f7da92a

Please sign in to comment.