Build and publish OCI image #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and publish OCI image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| image_name: | |
| type: string | |
| description: Image name | |
| required: true | |
| tags: | |
| type: string | |
| description: Image tag | |
| required: true | |
| publish: | |
| type: boolean | |
| description: Whether to publish the image | |
| default: false | |
| required: false | |
| workflow_call: | |
| inputs: | |
| image_name: | |
| type: string | |
| required: true | |
| tags: | |
| type: string | |
| required: true | |
| publish: | |
| type: boolean | |
| default: false | |
| required: false | |
| jobs: | |
| build-image: | |
| runs-on: ubuntu-latest | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ inputs.image_name }} | |
| TAGS: ${{ inputs.tags}} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Build image | |
| id: build-image | |
| uses: redhat-actions/buildah-build@v2 | |
| with: | |
| image: ${{ env.IMAGE_NAME }} | |
| tags: ${{ env.TAGS }} | |
| context: ./${{ env.IMAGE_NAME }} | |
| containerfiles: | | |
| ${{ env.IMAGE_NAME }}/${{ env.TAGS }}/Containerfile | |
| - name: Log in to ghcr.io | |
| if: inputs.publish == true | |
| uses: redhat-actions/podman-login@v1 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: t2linux | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push image to ghcr.io | |
| if: inputs.publish == true | |
| uses: redhat-actions/push-to-registry@v2 | |
| with: | |
| image: ${{ steps.build-image.outputs.image }} | |
| tags: ${{ steps.build-image.outputs.tags }} | |
| registry: ${{ env.REGISTRY }}/t2linux |