refactor: replace Docker build steps with silta-actions/build-push-im… #3
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 & Push Images | |
| on: | |
| push: | |
| branches: ["**"] | |
| paths-ignore: | |
| - "k8s/**" | |
| - "**.md" | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| REGISTRY: ${{ vars.REGISTRY || 'registry.wdr.io' }} | |
| REPO: ${{ github.event.repository.name }} | |
| jobs: | |
| # --------------------------------------------------------------- | |
| # Stage 1: Validate codebase. | |
| # Simple project has no application code to lint — just verify | |
| # the Dockerfile and static content are well-formed. | |
| # --------------------------------------------------------------- | |
| validate: | |
| name: Validate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Lint Dockerfile | |
| uses: hadolint/hadolint-action@v3.1.0 | |
| with: | |
| dockerfile: silta/nginx.Dockerfile | |
| failure-threshold: error | |
| # --------------------------------------------------------------- | |
| # Stage 2: Build and push Docker image. | |
| # --------------------------------------------------------------- | |
| build-image: | |
| name: Build & Push — nginx | |
| runs-on: ubuntu-latest | |
| needs: validate | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Build & push image | |
| uses: wunderio/silta-actions/build-push-image@v1 | |
| with: | |
| image-name: nginx | |
| dockerfile: silta/nginx.Dockerfile | |
| registry: ${{ env.REGISTRY }} | |
| registry-username: ${{ secrets.REGISTRY_USERNAME }} | |
| registry-password: ${{ secrets.REGISTRY_PASSWORD }} |