🐛 Run job with the cli command instead of harbor #52
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 Push Container Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - 'CICD*' | |
| workflow_dispatch: | |
| env: | |
| IMAGE_NAME: ghcr.io/${{ github.repository }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set image tag | |
| id: tag | |
| run: | | |
| if [ "$GITHUB_REF_NAME" = "main" ]; then | |
| echo "branch=latest" >> "$GITHUB_OUTPUT" | |
| else | |
| SANITIZED_TAG="$(printf '%s' "$GITHUB_REF_NAME" | tr -cs '[:alnum:]._-' '-' | cut -c1-128)" | |
| echo "branch=${SANITIZED_TAG}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build and push | |
| uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 | |
| with: | |
| context: . | |
| file: Containerfile | |
| push: true | |
| tags: | | |
| ${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.branch }} | |
| ${{ env.IMAGE_NAME }}:${{ github.sha }} |