This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from CircleCI to GitHub Actions (#15)
* 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
Showing
2 changed files
with
87 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
This file was deleted.
Oops, something went wrong.