|
1 | 1 | name: Image Builder |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - # Build and publish after updating the default branch |
6 | | - branches: |
7 | | - - main |
8 | | - paths-ignore: |
9 | | - - '.dockerignore' |
10 | | - - 'docs/*' |
11 | | - - 'LICENSE' |
12 | | - - 'README.md' |
13 | | - - 'example/*' |
14 | | - pull_request: |
15 | | - # Build, but don't push on pull requests |
16 | | - branches: |
17 | | - - main |
| 4 | + push: {} |
18 | 5 |
|
19 | 6 | jobs: |
20 | 7 | # Build images and push them |
21 | 8 | build: |
22 | | - name: Build Docker image |
| 9 | + name: Build tagged Docker image |
23 | 10 | runs-on: ubuntu-latest |
24 | 11 |
|
25 | 12 | steps: |
26 | | - - uses: actions/checkout@v4 |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
27 | 15 |
|
28 | | - - name: Build image |
29 | | - run: | |
30 | | - docker build \ |
31 | | - --tag=${{ github.repository }} \ |
32 | | - --tag=ghcr.io/${{ github.repository }} \ |
33 | | - . |
| 16 | + |
| 17 | + - name: Login to Docker Hub |
| 18 | + uses: docker/login-action@v3 |
| 19 | + with: |
| 20 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 21 | + password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 22 | + |
| 23 | + - name: Login to GitHub Container Registry |
| 24 | + uses: docker/login-action@v3 |
| 25 | + with: |
| 26 | + registry: ghcr.io |
| 27 | + username: ${{ github.actor }} |
| 28 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + |
| 30 | + - name: Docker meta |
| 31 | + id: meta |
| 32 | + uses: docker/metadata-action@v5 |
| 33 | + with: |
| 34 | + images: | |
| 35 | + openjournals/inara |
| 36 | + ghcr.io/openjournals/inara |
| 37 | + tags: | |
| 38 | + type=semver,pattern={{version}} |
| 39 | + type=edge,branch=main |
| 40 | +
|
| 41 | + - name: Build and push image |
| 42 | + id: push |
| 43 | + uses: docker/build-push-action@v5 |
| 44 | + with: |
| 45 | + context: '.' |
| 46 | + push: true |
| 47 | + tags: ${{ steps.meta.output.tags }} |
| 48 | + labels: ${{ steps.meta.output.labels }} |
34 | 49 |
|
35 | 50 | - name: Test image |
36 | | - run: | |
37 | | - make test |
38 | | -
|
39 | | - - name: Push to Docker Hub |
40 | | - if: >- |
41 | | - github.event_name == 'push' && |
42 | | - github.repository == 'openjournals/inara' |
43 | | - run: | |
44 | | - # Log into registry |
45 | | - echo "${{ secrets.DOCKER_HUB_TOKEN }}" | |
46 | | - docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin |
47 | | - docker push ${{ github.repository }} |
48 | | -
|
49 | | - - name: Push to GitHub Container Registry |
50 | | - if: >- |
51 | | - github.event_name == 'push' && |
52 | | - github.repository == 'openjournals/inara' |
53 | | - run: | |
54 | | - # Log into registry |
55 | | - echo "${{ secrets.GITHUB_TOKEN }}" | \ |
56 | | - docker login ghcr.io \ |
57 | | - -u ${{ github.actor }} \ |
58 | | - --password-stdin |
59 | | - docker push ghcr.io/${{ github.repository }} |
| 51 | + run: make test |
0 commit comments