diff --git a/.github/workflows/dockerfile-validation.yml b/.github/workflows/dockerfile-validation.yml index 5f8d3ac..4150528 100644 --- a/.github/workflows/dockerfile-validation.yml +++ b/.github/workflows/dockerfile-validation.yml @@ -1,4 +1,4 @@ -name: Dockerfile Validation +name: Docker Build and Publish on: push: @@ -13,28 +13,39 @@ on: - '.github/workflows/dockerfile-validation.yml' jobs: - validate-dockerfile: + docker: runs-on: ubuntu-latest - + permissions: + contents: read + packages: write + steps: - name: Checkout code uses: actions/checkout@v4 - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - + - name: Lint Dockerfile uses: hadolint/hadolint-action@v3.1.0 with: dockerfile: Dockerfile failure-threshold: warning - - - name: Build Docker image + + - name: Log in to GitHub Container Registry + if: github.event_name == 'push' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image (PR) / Build and push image (main) uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile - push: false - tags: test-build:latest + push: ${{ github.event_name == 'push' }} + tags: ghcr.io/okteto/deploy-preview:main cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max diff --git a/action.yml b/action.yml index 0e90164..6f62361 100644 --- a/action.yml +++ b/action.yml @@ -31,7 +31,7 @@ inputs: required: false runs: using: "docker" - image: "Dockerfile" + image: "docker://ghcr.io/okteto/deploy-preview:main" args: - ${{ inputs.name }} - ${{ inputs.timeout }}