diff options
-rw-r--r-- | .github/workflows/build-and-publish.yml | 76 | ||||
-rw-r--r-- | .github/workflows/main.yml | 18 |
2 files changed, 76 insertions, 18 deletions
diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..2d3a49d --- /dev/null +++ b/.github/workflows/build-and-publish.yml | |||
@@ -0,0 +1,76 @@ | |||
1 | name: Build and Publish Docker Image | ||
2 | |||
3 | on: | ||
4 | push: | ||
5 | branches: | ||
6 | - 'main' | ||
7 | paths-ignore: | ||
8 | - '**.md' | ||
9 | - '**.png' | ||
10 | tags: | ||
11 | - 'v*.*.*' | ||
12 | pull_request: | ||
13 | branches: | ||
14 | - 'main' | ||
15 | paths-ignore: | ||
16 | - '**.md' | ||
17 | - '**.png' | ||
18 | release: | ||
19 | types: [published] | ||
20 | workflow_dispatch: | ||
21 | |||
22 | jobs: | ||
23 | image-build: | ||
24 | runs-on: ubuntu-latest | ||
25 | steps: | ||
26 | - name: Checkout | ||
27 | uses: actions/checkout@v2 | ||
28 | |||
29 | - name: Docker meta | ||
30 | id: meta | ||
31 | uses: docker/metadata-action@v3 | ||
32 | with: | ||
33 | images: | | ||
34 | getferdi/ferdi-server | ||
35 | # ghcr.io/getferdi/ferdi-server | ||
36 | tags: | | ||
37 | type=ref,event=branch | ||
38 | type=ref,event=pr | ||
39 | type=semver,pattern={{version}} | ||
40 | type=semver,pattern={{major}}.{{minor}} | ||
41 | type=semver,pattern={{major}} | ||
42 | |||
43 | - name: Set up QEMU | ||
44 | uses: docker/setup-qemu-action@v1 | ||
45 | |||
46 | - name: Set up Docker Buildx | ||
47 | uses: docker/setup-buildx-action@v1 | ||
48 | |||
49 | - name: Login to DockerHub | ||
50 | if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | ||
51 | uses: docker/login-action@v1 | ||
52 | with: | ||
53 | username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
54 | password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
55 | |||
56 | - name: Login to GitHub Container Registry | ||
57 | if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | ||
58 | uses: docker/login-action@v1 | ||
59 | with: | ||
60 | registry: ghcr.io | ||
61 | username: ${{ github.repository_owner }} | ||
62 | password: ${{ secrets.GITHUB_TOKEN }} | ||
63 | |||
64 | - name: Build and push | ||
65 | id: docker_build | ||
66 | uses: docker/build-push-action@v2 | ||
67 | with: | ||
68 | context: . | ||
69 | file: ./Dockerfile | ||
70 | platforms: linux/amd64,linux/arm64 | ||
71 | push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | ||
72 | tags: ${{ steps.meta.outputs.tags }}, getferdi/ferdi-server:latest | ||
73 | labels: ${{ steps.meta.outputs.labels }} | ||
74 | |||
75 | - name: Image digest | ||
76 | run: echo ${{ steps.docker_build.outputs.digest }} | ||
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index e21943b..0000000 --- a/.github/workflows/main.yml +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | name: Trigger Docker Hub build | ||
2 | |||
3 | on: | ||
4 | release: | ||
5 | types: [published] | ||
6 | |||
7 | jobs: | ||
8 | build: | ||
9 | |||
10 | runs-on: ubuntu-latest | ||
11 | |||
12 | steps: | ||
13 | - name: Install HTTPie | ||
14 | run: sudo apt-get install httpie | ||
15 | |||
16 | - name: Send request to Docker Hub to trigger a build | ||
17 | run: > | ||
18 | http post https://hub.docker.com/api/build/v1/source/83564f19-c21a-4dae-9690-971aee3b2a3b/trigger/${{ env.HUB_TRIGGER_ID }}/call/' | ||