Skip to content

Rewrite for usage primarily on GitHub Actions #152

Rewrite for usage primarily on GitHub Actions

Rewrite for usage primarily on GitHub Actions #152

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: freckle/stack-cache-action@v2
- id: stack
uses: freckle/stack-action@v3
- uses: freckle/weeder-action@v2
with:
ghc-version: ${{ steps.stack.outputs.compiler-version }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: curl -L https://raw.githubusercontent.com/pbrisbin/dotfiles/master/hlint.yaml > .hlint.yaml
- uses: haskell/actions/hlint-setup@v2
- uses: haskell/actions/hlint-run@v2
with:
fail-on: warning
image:
runs-on: ubuntu-latest
steps:
- id: meta
uses: docker/metadata-action@v3
with:
images: restyled/restyler
tags: |
type=sha,prefix=,priority=1000
type=edge,branch=main
type=ref,event=tag
- id: buildx
uses: docker/setup-buildx-action@v1
- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-image-${{ github.sha }}
restore-keys: |
${{ runner.os }}-image-
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Avoids ever-growing cache hitting limits
- run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
outputs:
tags: ${{ steps.meta.outputs.tags }}
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [build, image]
steps:
- name: setup
run: |
cat > ~/.netrc <<EOF
machine api.heroku.com
login $HEROKU_EMAIL
password $HEROKU_API_KEY
machine git.heroku.com
login $HEROKU_EMAIL
password $HEROKU_API_KEY
EOF
env:
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
- name: deploy
run: |
read -r tag <<'EOM'
${{ needs.image.outputs.tags }}
EOM
heroku config:set --app restyled-io "RESTYLER_IMAGE=$tag"
- uses: desiderati/github-action-pushover@v1
if: ${{ always() }}
with:
job-status: ${{ job.status }}
pushover-api-token: ${{ secrets.PUSHOVER_API_TOKEN }}
pushover-user-key: ${{ secrets.PUSHOVER_USER_KEY }}