Replace task.sh with Taskfile #32
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
--- | |
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 Task | |
uses: arduino/setup-task@v2 | |
with: | |
version: 3.x | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run static code tests | |
run: | | |
task test:static | |
- 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 }} |