update to run the scheduled job every hour and use the pear's timezone #755
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: Continuous Integration and Delivery | |
# Define workflow that runs when changes are pushed to the | |
# `main` branch or pushed to a PR branch that targets the `main` | |
# branch. Change the branch name if your project uses a | |
# different name for the main branch like "master" or "production". | |
on: | |
push: | |
branches: [ "main" ] # adapt branch for project | |
pull_request: | |
branches: [ "main" ] # adapt branch for project | |
# Sets the ENV `MIX_ENV` to `test` for running tests | |
env: | |
MIX_ENV: test | |
HONEYCOMB_KEY: ${{ secrets.HONEYCOMB_KEY }} | |
ADMIN_USER: ${{ secrets.ADMIN_USER }} | |
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }} | |
TIMBER_KEY: ${{ secrets.TIMBER_KEY }} | |
TIMBER_SOURCE_ID: ${{ secrets.TIMBER_SOURCE_ID }} | |
SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID }} | |
SLACK_CLIENT_SECRET: ${{ secrets.SLACK_CLIENT_SECRET }} | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
CLOAK_KEY: ${{ secrets.CLOAK_KEY }} | |
permissions: | |
contents: read | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
name: Run checks on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} | |
strategy: | |
# Specify the OTP and Elixir versions to use when building | |
# and running the workflow steps. | |
matrix: | |
otp: [ '26.2.1' ] # Define the OTP version [required] | |
elixir: [ '1.16.0-otp-26' ] # Define the elixir version [required] | |
steps: | |
# Step: Check out the code. | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step: Setup Elixir + Erlang and build the application. | |
- name: Build the Application | |
uses: ./.github/actions/build | |
# Step: Check for unused dependencies. | |
# This step fails if there are unused dependencies in the lock. | |
- name: Check for unused dependencies | |
run: mix deps.unlock --check-unused | |
# Step: Compile the project treating any warnings as errors. | |
- name: Compiles without warnings | |
run: mix compile --warnings-as-errors | |
# Step: Check that the checked in code has already been formatted. | |
# This step fails if something was found unformatted. | |
- name: Check Formatting | |
run: mix format --check-formatted | |
# Step: Check that the checked in code has a consistent style. | |
# This step fails if issues are found. | |
- name: Static Analysis | |
run: mix credo --strict | |
test: | |
# Set up a Postgres DB service. By default, Phoenix applications | |
# use Postgres. This creates a database for running tests. | |
# Additional services can be defined here if required. | |
services: | |
db: | |
image: postgres:12 | |
ports: [ '5432:5432' ] | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
runs-on: ubuntu-latest | |
name: Test on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} | |
strategy: | |
# Specify the OTP and Elixir versions to use when building | |
# and running the workflow steps. | |
matrix: | |
otp: [ '26.2.1' ] # Define the OTP version [required] | |
elixir: [ '1.16.0-otp-26' ] # Define the elixir version [required] | |
steps: | |
# Step: Check out the code. | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step: Setup Elixir + Erlang and build the application. | |
- name: Build the Application | |
uses: ./.github/actions/build | |
# Step: Execute the tests. | |
- name: Run tests | |
run: mix test --trace | |
deploy: | |
name: Deploy to fly.io | |
runs-on: ubuntu-latest | |
needs: [ check, test ] | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- run: flyctl deploy --remote-only | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
on_failure: | |
needs: [ check, test, deploy ] | |
if: ${{ failure() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notify on failure | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: general | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_TITLE: Pears CI/CD is red! | |
SLACK_MESSAGE: 'The build is red https://github.com/marcdel/pears/actions?query=branch%3Amain' | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |