-
Notifications
You must be signed in to change notification settings - Fork 10
100 lines (98 loc) · 3.06 KB
/
autoupdate-other-derivations.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
name: Autoupdate other derivations
on:
schedule:
- cron: '0 5 * * 1,3,5'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
update:
timeout-minutes: 600
name: Update Toolbox components
runs-on: ubuntu-latest
outputs:
branch: '${{ steps.mr.outputs.branch }}'
updates: '${{ steps.mr.outputs.updates }}'
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v22
- name: Setup binary cache
uses: cachix/cachix-action@v12
with:
name: toolbox
skipPush: true
- name: Check for updates
run : |
nix-shell --command autoupdate/update.py
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
SOURCE_FILTER: '(?!terraform.*)'
- name: Create MR
id: mr
run: |
git config --global user.name $GITHUB_ACTOR
git config --global user.email "action@github.com"
if [ `git status --porcelain=v2 | wc -l` -ne 0 ]; then
echo "Changes detected ! Creating pull request..."
git fetch --all
for branch in `git branch --list -a "*autoupdate-packages-*" | awk -F'/' '{if($3 != "") print $3}'`;do
git push origin --delete ${branch} -q
done
BRANCH_NAME=autoupdate-packages-$(date '+%d-%m-%y')
git checkout -b $BRANCH_NAME -q
git add -A
git commit -m "autoupdate: $(date '+%d-%m-%y')" -q
mv changes.md changes_wip.md
git add changes_wip.md
git commit -m "add update changelog"
git push origin $BRANCH_NAME
echo ::set-output name=updates::true
echo ::set-output name=branch::$BRANCH_NAME
else
echo ::set-output name=updates::false
fi
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
build:
if: ${{ needs.update.outputs.updates == 'true' }}
needs:
- update
timeout-minutes: 600
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
ref: '${{ needs.update.outputs.branch }}'
- name: Install Nix
uses: cachix/install-nix-action@v22
- name: Setup binary cache
uses: cachix/cachix-action@v12
with:
name: toolbox
skipPush: true
- name: Build packages
run: |
nix-build
commit:
needs:
- build
- update
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: '${{ needs.update.outputs.branch }}'
fetch-depth: 2
- name: open pr
run: |
git config --global user.name $GITHUB_ACTOR
git config --global user.email "action@github.com"
cp changes_wip.md changes.md
git reset --hard "HEAD^"
git push --force
hub pull-request -F changes.md
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'