-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (93 loc) · 2.99 KB
/
schedule.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
name: '⏱️ Schedule workflow run'
on:
push:
branches:
- main
paths:
- images/node/**
- images/prestashop/**
- images/shopware/**
- images/wordpress/**
workflow_dispatch:
inputs:
image:
description: 'Image to schedule the workflow for (for testing purposes)'
required: true
type: choice
options:
- node
- prestashop
- shopware
- wordpress
jobs:
schedule:
runs-on: ubuntu-22.04
strategy:
matrix:
image:
- node
- prestashop
- shopware
- wordpress
steps:
- uses: actions/checkout@v4
- uses: tj-actions/changed-files@v45
id: changed-files
if: inputs.image == ''
with:
files: 'images/${{ matrix.image }}/**'
- name: 'Prepare'
if: steps.changed-files.outputs.test_any_changed == 'true' || inputs.image == matrix.image
id: prepare
env:
IMAGE: ${{ matrix.image }}
shell: bash
#language=bash
run: |
echo "run=true" >> $GITHUB_OUTPUT
echo "filename=.lock-$IMAGE.txt" >> $GITHUB_OUTPUT
echo "artifact-name=workflow-lock-$IMAGE" >> $GITHUB_OUTPUT
- name: 'Check if lock file exists'
if: steps.prepare.outputs.run == 'true'
uses: ./.github/actions/check-artifact
id: check-lock
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ steps.prepare.outputs.artifact-name }}
- if: steps.prepare.outputs.run == 'true' && steps.check-lock.outputs.exists == 'true'
env:
IMAGE: ${{ matrix.image }}
shell: bash
#language=bash
run: |
echo "⏱️ There was already a run scheduled for \`$IMAGE\`." >> $GITHUB_STEP_SUMMARY
- name: 'Create lock file'
if: steps.prepare.outputs.run == 'true' && steps.check-lock.outputs.exists == 'false'
env:
FILENAME: ${{ steps.prepare.outputs.filename }}
shell: bash
#language=bash
run: |
echo "$(date)" > "$FILENAME"
- name: 'Upload lock artifact'
uses: actions/upload-artifact@v4
if: steps.prepare.outputs.run == 'true' && steps.check-lock.outputs.exists == 'false'
with:
if-no-files-found: error
include-hidden-files: true
name: ${{ steps.prepare.outputs.artifact-name}}
path: ${{ steps.prepare.outputs.filename }}
- if: steps.prepare.outputs.run == 'true' && steps.check-lock.outputs.exists == 'false'
env:
IMAGE: ${{ matrix.image }}
shell: bash
#language=bash
run: |
echo "✅ A run for \`$IMAGE\` was scheduled." >> $GITHUB_STEP_SUMMARY
notify-on-failure:
needs:
- schedule
if: always() && contains(needs.*.result, 'failure')
uses: myparcelnl/actions/.github/workflows/notify-on-failure.yml@v4
secrets: inherit