]>
Commit | Line | Data |
---|---|---|
1 | name: Build and push docker image | |
2 | ||
3 | on: | |
4 | pull_request: | |
5 | push: | |
6 | branches: | |
7 | - 'master' | |
8 | tags: | |
9 | - '*' | |
10 | ||
11 | env: | |
12 | TEST_TAG: fretlink/link | |
13 | ||
14 | jobs: | |
15 | docker: | |
16 | runs-on: ubuntu-latest | |
17 | strategy: | |
18 | matrix: | |
19 | base_os: | |
20 | - debian | |
21 | - alpine | |
22 | steps: | |
23 | - name: Checkout | |
24 | uses: actions/checkout@v2 | |
25 | - name: Set up Docker Buildx | |
26 | uses: docker/setup-buildx-action@v1 | |
27 | - name: Build and export to Docker | |
28 | uses: docker/build-push-action@v2 | |
29 | with: | |
30 | context: . | |
31 | file: ${{ matrix.base_os }}/Dockerfile | |
32 | load: true | |
33 | tags: ${{ env.TEST_TAG }} | |
34 | - name: Test | |
35 | run: | | |
36 | docker run --rm ${{ env.TEST_TAG }} 'nix-channel --list' | |
37 | docker run --rm ${{ env.TEST_TAG }} 'nix-env -iA nixpkgs.hello && test "$(hello)" = "Hello, world!"' | |
38 | - name: Get the version | |
39 | if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
40 | id: get_version | |
41 | run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
42 | - name: Login to DockerHub | |
43 | if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
44 | uses: docker/login-action@v1 | |
45 | with: | |
46 | username: ${{ secrets.DOCKERHUB_USERNAME }} | |
47 | password: ${{ secrets.DOCKERHUB_TOKEN }} | |
48 | - name: Build and push | |
49 | if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
50 | id: docker_build | |
51 | uses: docker/build-push-action@v2 | |
52 | with: | |
53 | push: true | |
54 | context: . | |
55 | file: ${{ matrix.base_os }}/Dockerfile | |
56 | tags: fretlink/nix:${{ steps.get_version.outputs.VERSION }}-${{ matrix.base_os }} |