Skip to content

Commit

Permalink
Merge pull request #17 from nansencenter/github_actions
Browse files Browse the repository at this point in the history
Migrate to GitHub actions
  • Loading branch information
akorosov authored Jun 24, 2021
2 parents 001fb6b + 7b708ce commit 3334e7e
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 77 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/build_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
name: "Build Docker images"
on:
push:
branches: ['**']
release:
types: [released]
env:
IMAGE_NAME: "${{ secrets.DOCKER_ORG }}/nansat_base"
jobs:
build_standard_docker_image:
runs-on: 'ubuntu-20.04'
steps:
- name: 'Checkout repository'
uses: actions/checkout@v2

- name: "Extract tag name"
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]];then
TAG="${GITHUB_REF#refs/tags/}"
else
TAG='tmp'
fi
echo "::set-output name=VERSION::${TAG}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-standard-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-standard-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Build docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build_slim_docker_image:
runs-on: 'ubuntu-20.04'
steps:
- name: 'Checkout repository'
uses: actions/checkout@v2

- name: "Extract tag name"
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]];then
TAG="${GITHUB_REF#refs/tags/}"
else
TAG='tmp'
fi
echo "::set-output name=VERSION::${TAG}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-slim-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-slim-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Build docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile_slim
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: |
${{ env.IMAGE_NAME }}:latest-slim
${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }}-slim
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
...
65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

12 changes: 0 additions & 12 deletions docker_push.sh

This file was deleted.

0 comments on commit 3334e7e

Please sign in to comment.