diff options
author | Ismaël Bouya <ismael.bouya@fretlink.com> | 2021-10-13 17:27:37 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2021-10-14 11:06:32 +0200 |
commit | a7aa57a9b8af87d0992424f0e75de3b7bc8b4811 (patch) | |
tree | 4bc5c0ce85fb6afda7c3f48625045bae9a85b4d0 /.github/workflows | |
parent | 51ca88242693d27bff139f25e363c0c629dd05b5 (diff) | |
download | docker-nix-a7aa57a9b8af87d0992424f0e75de3b7bc8b4811.tar.gz docker-nix-a7aa57a9b8af87d0992424f0e75de3b7bc8b4811.tar.zst docker-nix-a7aa57a9b8af87d0992424f0e75de3b7bc8b4811.zip |
Use github action
Diffstat (limited to '.github/workflows')
-rw-r--r-- | .github/workflows/docker.yml | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..62cea6d --- /dev/null +++ b/.github/workflows/docker.yml | |||
@@ -0,0 +1,56 @@ | |||
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 -it --rm ${{ env.TEST_TAG }} 'nix-channel --list' | ||
37 | docker run -it --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 }} | ||