]> git.immae.eu Git - github/fretlink/docker-nix.git/commitdiff
Use github action 12/head
authorIsmaël Bouya <ismael.bouya@fretlink.com>
Wed, 13 Oct 2021 15:27:37 +0000 (17:27 +0200)
committerIsmaël Bouya <ismael.bouya@fretlink.com>
Thu, 14 Oct 2021 09:06:32 +0000 (11:06 +0200)
.github/workflows/docker.yml [new file with mode: 0644]
.travis.yml [deleted file]

diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644 (file)
index 0000000..62cea6d
--- /dev/null
@@ -0,0 +1,56 @@
+name: Build and push docker image
+
+on:
+  pull_request:
+  push:
+    branches:
+      - 'master'
+    tags:
+      - '*'
+
+env:
+  TEST_TAG: fretlink/link
+
+jobs:
+  docker:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        base_os:
+          - debian
+          - alpine
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v1
+      - name: Build and export to Docker
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          file: ${{ matrix.base_os }}/Dockerfile
+          load: true
+          tags: ${{ env.TEST_TAG }}
+      - name: Test
+        run: |
+          docker run -it --rm ${{ env.TEST_TAG }} 'nix-channel --list'
+          docker run -it --rm ${{ env.TEST_TAG }} 'nix-env -iA nixpkgs.hello && test "$(hello)" = "Hello, world!"'
+      - name: Get the version
+        if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
+        id: get_version
+        run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
+      - name: Login to DockerHub
+        if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
+        uses: docker/login-action@v1
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+      - name: Build and push
+        if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
+        id: docker_build
+        uses: docker/build-push-action@v2
+        with:
+          push: true
+          context: .
+          file: ${{ matrix.base_os }}/Dockerfile
+          tags: fretlink/nix:${{ steps.get_version.outputs.VERSION }}-${{ matrix.base_os }}
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644 (file)
index 6da21de..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# .travis.yml
-
-services:
-  - docker
-
-addons:
-  apt:
-    packages:
-      - docker-ce
-
-matrix:
-  include:
-    - env: BASE_OS=alpine
-    - env: BASE_OS=debian
-
-script:
-  - docker build --pull -t fretlink/nix -f ${BASE_OS}/Dockerfile .
-  - docker run -it --rm fretlink/nix 'nix-channel --list'
-  - docker run -it --rm fretlink/nix 'nix-env -iA nixpkgs.hello && test "$(hello)" = "Hello, world!"'