Skip to content

CI/CD

CI/CD #29

Workflow file for this run

---
name: CI/CD
on:
pull_request:
push:
branches:
- main
tags:
- 'v*'
schedule:
- cron: "0 0 * * 0"
jobs:
cicd:
name: CI/CD
runs-on: ubuntu-latest
steps:
- name: Checkout the repo at current context
uses: actions/checkout@v2
- name: Install test dependencies
run: ./tasks.sh test:install-depends
- name: Run static code tests
run: |
./tasks.sh -e test:lint
./tasks.sh -e test:units
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: bcbrookman/buoy
tags: |
type=raw, value=latest
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build Docker image
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
load: true
tags: buoy:test
- name: Run and test that the image works
run: |
docker run --name buoy -d buoy:test
docker exec --tty buoy flask --version
- name: Login to DockerHub
uses: docker/login-action@v1
# Only push from main branch, and not from PRs
if: |
github.ref == 'refs/heads/main' &&
github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image to DockerHub
uses: docker/build-push-action@v3
# Only push from main branch, and not from PRs
if: |
github.ref == 'refs/heads/main' &&
github.event_name != 'pull_request'
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}