|
1 | | -name: Docker Publish |
| 1 | +name: Docker Build |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: ["main"] |
6 | | - # Publish semver tags as releases. |
7 | | - tags: ["v*.*.*"] |
8 | | - |
9 | | -env: |
10 | | - # Use docker.io for Docker Hub if empty |
11 | | - REGISTRY: ghcr.io |
12 | | - # github.repository as <account>/<repo> |
13 | | - IMAGE_NAME: ${{ github.repository }} |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + - "feature/**" |
| 9 | + - "hotfix/**" |
| 10 | + tags: |
| 11 | + - "v*.*.*" |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + - develop |
14 | 16 |
|
15 | 17 | jobs: |
16 | | - build: |
17 | | - runs-on: ubuntu-latest |
18 | | - permissions: |
19 | | - contents: read |
20 | | - packages: write |
21 | | - |
22 | | - steps: |
23 | | - - name: Checkout repository |
24 | | - uses: actions/checkout@v3 |
25 | | - |
26 | | - # Install the cosign tool except on PR |
27 | | - |
28 | | - # Set up BuildKit Docker container builder to be able to build |
29 | | - # multi-platform images and export cache |
30 | | - # https://github.com/docker/setup-buildx-action |
31 | | - - name: Set up Docker Buildx |
32 | | - uses: docker/setup-buildx-action@v3 # v3.0.0 |
33 | | - |
34 | | - # Login against a Docker registry except on PR |
35 | | - # https://github.com/docker/login-action |
36 | | - - name: Log into registry ${{ env.REGISTRY }} |
37 | | - if: github.event_name != 'pull_request' |
38 | | - uses: docker/login-action@v3 # v3.0.0 |
39 | | - with: |
40 | | - registry: ${{ env.REGISTRY }} |
41 | | - username: ${{ github.actor }} |
42 | | - password: ${{ secrets.GITHUB_TOKEN }} |
43 | | - |
44 | | - # Extract metadata (tags, labels) for Docker |
45 | | - # https://github.com/docker/metadata-action |
46 | | - - name: Extract Docker metadata |
47 | | - id: meta |
48 | | - uses: docker/metadata-action@v5 # v5.0.0 |
49 | | - with: |
50 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
51 | | - |
52 | | - # Build and push Docker image with Buildx (don't push on PR) |
53 | | - # https://github.com/docker/build-push-action |
54 | | - - name: Build and push Docker image |
55 | | - id: build-and-push |
56 | | - uses: docker/build-push-action@v5 # v5.0.0 |
57 | | - with: |
58 | | - context: . |
59 | | - platforms: linux/amd64,linux/arm64 |
60 | | - push: ${{ github.event_name != 'pull_request' }} |
61 | | - tags: ${{ steps.meta.outputs.tags }} |
62 | | - labels: ${{ steps.meta.outputs.labels }} |
63 | | - cache-from: type=gha |
64 | | - cache-to: type=gha,mode=max |
| 18 | + docker: |
| 19 | + uses: pnstack/actions/docker-publish@main |
| 20 | + with: |
| 21 | + platforms: linux/amd64,linux/arm64 |
| 22 | + dockerfile: Dockerfile |
| 23 | + context: . |
| 24 | + push_enabled: true |
| 25 | + registry: ghcr.io |
0 commit comments