prod #30
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: prod | |
on: | |
push: | |
branches: | |
- "master" | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: "Log level" | |
required: true | |
default: "warning" | |
schedule: | |
- cron: "0 0 1 */1 *" | |
# - cron: "*/5 * * * *" # 5 min testing | |
jobs: | |
ci: | |
name: ci | |
runs-on: ubuntu-latest | |
env: | |
using_act: ${{ github.actor == 'nektos/act'}} | |
is_cron: ${{ github.event_name == 'schedule' }} | |
steps: | |
- name: Checkout. | |
uses: actions/checkout@v2 | |
- name: Build the image. | |
run: make | |
# Act sadly needs some specific behavior here, hence the branching | |
- name: Run the container (on GitHub). | |
if: env.using_act == 'false' | |
run: make run | |
- name: Run the container (using Act). | |
if: env.using_act == 'true' | |
run: make ACT_GITHUB_WORKSPACE=$GITHUB_WORKSPACE run-container-act | |
- name: Wait for the container to spin up. | |
run: sleep 10 | |
- name: Test the container. | |
run: make test | |
- name: Cleanup container (using Act). | |
if: env.using_act == 'true' | |
run: make clean-container | |
deploy: | |
needs: ci | |
name: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: carlodepieri/docker-archlinux-ansible:latest |