Rewrite for usage primarily on GitHub Actions #261
Workflow file for this run
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 | |
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@v4 | |
- id: stack | |
uses: freckle/stack-action@v5 | |
# - uses: freckle/weeder-action@v2 | |
# with: | |
# ghc-version: ${{ steps.stack.outputs.compiler-version }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: binaries | |
path: | | |
${{ steps.stack.outputs.local-install-root }}/bin/restyle-gha | |
if-no-files-found: error | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- 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@v5 | |
with: | |
images: restyled/restyler | |
tags: | | |
type=sha,prefix=,priority=1000 | |
type=edge,branch=main | |
type=ref,event=tag | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- uses: docker/build-push-action@v5 | |
with: | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: | |
tags: ${{ steps.meta.outputs.tags }} | |
action: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
# BEGIN actions/setup | |
- uses: actions/download-artifact@v4 | |
with: | |
name: binaries | |
path: ./tmp | |
- run: chmod +x ./tmp/restyle-gha | |
# END actions/setup | |
- id: restyler | |
uses: ./actions/run | |
with: | |
binary: ./tmp/restyle-gha | |
- id: restyler2 | |
run: | | |
echo "restyled-head=restyled/pb/action" >>"$GITHUB_OUTPUT" | |
- run: | | |
cat <<'EOM' | |
if: ${{ steps.restyler.outputs.differences == 'true' }} | |
base: ${{ github.event.pull_request.head.ref }} | |
branch: ${{ steps.restyler.outputs.restyled-head }} | |
title: ${{ steps.restyler.outputs.restyled-title }} | |
body: ${{ steps.restyler.outputs.restyled-body }} | |
labels: ${{ steps.restyler.outputs.restyled-labels }} | |
reviewers: ${{ steps.restyler.outputs.restyled-reviewers }} | |
team-reviewers: ${{ steps.restyler.outputs.restyled-team-reviewers }} | |
EOM | |
- run: | | |
cat <<'EOM' | |
if: ${{ steps.restyler2.outputs.differences == 'true' }} | |
base: ${{ github.event.pull_request.head.ref }} | |
branch: ${{ steps.restyler2.outputs.restyled-head }} | |
title: ${{ steps.restyler2.outputs.restyled-title }} | |
body: ${{ steps.restyler2.outputs.restyled-body }} | |
labels: ${{ steps.restyler2.outputs.restyled-labels }} | |
reviewers: ${{ steps.restyler2.outputs.restyled-reviewers }} | |
team-reviewers: ${{ steps.restyler2.outputs.restyled-team-reviewers }} | |
EOM | |
- if: ${{ steps.restyler.outputs.differences == 'true' }} | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
base: ${{ github.event.pull_request.head.ref }} | |
branch: ${{ steps.restyler.outputs.restyled-head }} | |
title: ${{ steps.restyler.outputs.restyled-title }} | |
body: ${{ steps.restyler.outputs.restyled-body }} | |
labels: ${{ steps.restyler.outputs.restyled-labels }} | |
reviewers: ${{ steps.restyler.outputs.restyled-reviewers }} | |
team-reviewers: ${{ steps.restyler.outputs.restyled-team-reviewers }} | |
delete-branch: true | |
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 }} |