-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
72 lines (69 loc) · 2.48 KB
/
action.yml
File metadata and controls
72 lines (69 loc) · 2.48 KB
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
name: "Web changes detector"
author: "Dmitry Vasiliev"
description: "Detect changes in web pages and notify via GitHub Actions"
branding:
icon: "check-circle"
color: "blue"
inputs:
config:
description: "Configuration for the web changes detector"
required: true
jobs:
description: "List of jobs to run for web changes detection"
required: true
runs:
using: "composite"
steps:
- name: "Set up environment"
shell: bash
run: |
echo "CONFIG_PATH=${{ github.workspace }}/config.yaml" >> $GITHUB_ENV
echo "JOBS_PATH=${{ github.workspace }}/jobs.yaml" >> $GITHUB_ENV
echo "SNAPSHOTS_DB=${{ github.workspace }}/snapshots.db" >> $GITHUB_ENV
echo "HOOKS_PATH=${{ github.action_path }}/hooks.py" >> $GITHUB_ENV
echo "WEBCHANGES_VERSION=3.30.0" >> $GITHUB_ENV
echo "PYTHON_VERSION=3.10" >> $GITHUB_ENV
- name: "Write configs to files"
shell: bash
run: |
echo '${{ inputs.config }}' > $CONFIG_PATH
echo '${{ inputs.jobs }}' > $JOBS_PATH
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
- name: "Install webchanges package"
shell: bash
run: |
pip install webchanges==${{ env.WEBCHANGES_VERSION }}
- name: "Compute SHA-256 of configs input"
shell: bash
run: |
# Compute the hash of the configs input and store it in an environment variable
JOB_HASH=$(sha256sum ${{ env.JOBS_PATH }} | awk '{ print $1 }')
# Compute cache key based on the hashes
echo "CACHE_KEY=${{ runner.os }}-snapshots-${JOB_HASH}" >> $GITHUB_ENV
- name: "Restore cache snapshots database"
id: cache-db
uses: actions/cache/restore@v4
with:
path: "${{ env.SNAPSHOTS_DB }}"
key: "${{ env.CACHE_KEY }}"
- name: "Check if snapshots database exists"
shell: bash
run: |
if [ ! -f $SNAPSHOTS_DB ]; then
echo "No snapshots database found, creating a new one."
else
echo "Snapshots database found, using existing one."
fi
- name: "Run web changes detection"
shell: bash
run: |
webchanges --config ${{ env.CONFIG_PATH }} --jobs ${{ env.JOBS_PATH }} --hooks ${{ env.HOOKS_PATH }} --database ${{ env.SNAPSHOTS_DB }}
- name: "Cache snapshots database"
uses: actions/cache/save@v4
with:
path: "${{ env.SNAPSHOTS_DB }}"
key: "${{ env.CACHE_KEY }}"