Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Migrate from CircleCI to GitHub Actions (#15)
Browse files Browse the repository at this point in the history
* Migrate from CircleCI to GitHub Actions

* Adjust if logic

* Test it

* Safer matching + test it further

* Checkout code so we can use the Makefile

* :aff:

* Stop the várzea
  • Loading branch information
Igor Ribeiro Sucupira authored Dec 3, 2021
1 parent 676cad4 commit bfe1936
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 29 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: build_and_push

on:
pull_request:
push:
branches: [master]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:

build_docker:
name: Build Docker image
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Docker image and save it to a file
run: |
DOCKER_REPO=vivareal make docker_image
mkdir -p /tmp/docker-cache
docker save -o /tmp/docker-cache/x9.tar vivareal/x9:latest
- name: Cache Docker image for further jobs in this workflow run
uses: actions/upload-artifact@v2
with:
name: docker-image-cache
path: /tmp/docker-cache/
retention-days: 1

push_master_docker:
if: github.ref == 'refs/heads/master'
name: Push Docker image with tag master
needs: build_docker
runs-on: ubuntu-20.04
env:
DOCKER_REPO: vivareal
DOCKER_IMAGE_VERSION: master
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download cached Docker image
uses: actions/download-artifact@v2
with:
name: docker-image-cache
path: /tmp/docker-cache/
- name: Load Docker image and tag it as master
run: |
docker load < /tmp/docker-cache/x9.tar
make docker_tag
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push Docker image with tag master
run: make docker_push

push_release_docker:
if: "startsWith(github.ref, 'refs/tags/v')"
name: Push Docker image according to release
needs: build_docker
runs-on: ubuntu-20.04
env:
DOCKER_REPO: vivareal
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download cached Docker image
uses: actions/download-artifact@v2
with:
name: docker-image-cache
path: /tmp/docker-cache/
- name: Load Docker image and tag it according to current release
run: |
docker load < /tmp/docker-cache/x9.tar
make docker_tag DOCKER_IMAGE_VERSION=${GITHUB_REF#refs/tags/}
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push Docker image with release tag
run: make docker_push DOCKER_IMAGE_VERSION=${GITHUB_REF#refs/tags/}
- name: Push Docker image with latest tag if this version is stable
run: |
if [[ "${{ github.ref }}" =~ "^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$" ]]; then
make docker_push DOCKER_IMAGE_VERSION=latest
fi
29 changes: 0 additions & 29 deletions circle.yml

This file was deleted.

0 comments on commit bfe1936

Please sign in to comment.