-
Notifications
You must be signed in to change notification settings - Fork 15
135 lines (117 loc) · 3.53 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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.sha }}
# TODO: 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
- if: ${{ steps.restyler.outputs.differences == 'true' }}
uses: peter-evans/create-pull-request@v6
with:
branch: ${{ steps.restyler.outputs.restyled-branch-name }}
base: ${{ github.event.pull_request.head.ref }}
title: ${{ steps.restyler.outputs.restyled-pr-title }}
body: ${{ steps.restyler.outputs.restyled-pr-body }}
delete-branch: true
# TODO:
# labels
# reviewers
# team-reviewers
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 }}