diff --git a/.github/workflows/call_jobs.yml b/.github/workflows/call_jobs.yml new file mode 100644 index 000000000..ee6410366 --- /dev/null +++ b/.github/workflows/call_jobs.yml @@ -0,0 +1,28 @@ +name: Call reusable workflows + +on: + pull_request: + branches: + - main + - devel + types: + - closed + paths: + - '.github/workflows/reuse-build-and-publish-amd.yml' + - '.devcontainer/devcontainer.json' + - 'Dockerfile' + - 'reinstall-cmake.sh' + - 'VERSION' + +jobs: + call-workflow-amd64: + permissions: + contents: read + packages: write + uses: ./.github/workflows/reuse-build-and-publish.yml + with: + image_name: ${{ github.repository }} + ref_name: ${{ github.ref_name }} + actor: ${{ github.actor }} + registry: ghcr.io + secrets: inherit diff --git a/.github/workflows/reuse-build-publish-amd.yml b/.github/workflows/reuse-build-publish-amd.yml new file mode 100644 index 000000000..ccaec559c --- /dev/null +++ b/.github/workflows/reuse-build-publish-amd.yml @@ -0,0 +1,72 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Build and publish amd 64 Docker image + +on: + workflow_call: + inputs: + image_name: + description: image name + required: true + type: string + ref_name: + description: ref name + required: true + type: string + actor: + description: actor + required: true + type: string + registry: + description: registry + required: true + type: string +permissions: + contents: read + packages: write + +jobs: + reuse-build-and-push: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Extract version number + run: | + VER=$(cat VERSION) + echo "VERSION=$VER" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ inputs.registry }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ inputs.registry }}/${{ inputs.image_name }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern=${{ env.VERSION }} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + pull: true + tags: ${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.ref_name }} + build-args: | + CONTAINER_VERSION=${{ env.VERSION }} + labels: ${{ steps.meta.outputs.labels }}