-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
135 additions
and
41 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# Author: [email protected] | ||
# Maintainers: [email protected] | ||
# Description: This workflow is responsible for backing up the dashboards of the Erigon project. | ||
# Status: Mergeable for testing | ||
|
||
name: Dashboards backup | ||
|
||
env: | ||
GREEN: '\033[0;32m' | ||
RED: '\033[0;31m' | ||
YELLOW: '\033[0;33m' | ||
NOCOLOUR: '\033[0m' | ||
ERIGON_BRANCH: main | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
TEMPLATE_BRANCH: | ||
required: false | ||
type: string | ||
default: main | ||
description: 'The branch to pull the backup script from (default: main)' | ||
|
||
jobs: | ||
# | ||
# NOTE: This workflow splits the backup process in 3 jobs even though 2 (or even 1 if you're particularly naive) would have been enough. I decided to do that just as a reference for passing data between jobs. The overhead is minimal. | ||
# | ||
preparation: | ||
runs-on: ubuntu-latest | ||
environment: dashboards_backups | ||
steps: | ||
- name: Pull backup script from ${{ inputs.TEMPLATE_BRANCH}} branch | ||
run: | | ||
set +x | ||
curl -L -H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3.raw" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/erigontech/scripts/contents/dashboards/dashboard-backup.sh?ref=${{ inputs.TEMPLATE_BRANCH}} -o /tmp/dashboard-backup | ||
- name: Upload dashboard-backup | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dashboard-backup | ||
path: /tmp/dashboard-backup | ||
retention-days: 1 | ||
|
||
|
||
backup_dashboard: | ||
needs: preparation | ||
runs-on: ubuntu-latest | ||
environment: dashboards_backups | ||
strategy: | ||
matrix: | ||
# For each dashboard add an entry in the list here below (and add an entry in the dictionary within the backup script too!) | ||
dashboard: [erigon_custom_metrics] | ||
env: | ||
DASHBOARDS_AUTH_TOKEN: ${{ secrets.DASHBOARDS_AUTH_TOKEN }} | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
DASHBOARDS_GIT_CONFIG: ${{ secrets.DASHBOARDS_GIT_CONFIG }} | ||
steps: | ||
- name: Clone erigon from ${{ env.ERIGON_BRANCH }} branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.ERIGON_BRANCH }} | ||
fetch-depth: 1 | ||
path: ${{ github.workspace }}/erigon | ||
|
||
- name: Move repository to $HOME # as the backup script expects it to be there | ||
run: mv ${{ github.workspace }}/erigon $HOME/ | ||
|
||
- name: Set-up git | ||
run: | | ||
echo ${{ secrets.DASHBOARDS_GIT_CONFIG }} | base64 -d > $HOME/.gitconfig | ||
- name: Download dashboard-backup | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dashboard-backup | ||
path: /tmp | ||
|
||
- name: Set dashboard-backup permissions | ||
run: chmod +x /tmp/dashboard-backup | ||
|
||
- name: BACKUP OF ${{ matrix.dashboard }} DASHBOARD | ||
run: | | ||
set +x | ||
echo -e "${{ env.GREEN }} I'm processing the ${{ matrix.dashboard }} dashboard... ${{ env.NOCOLOUR }}" | ||
/tmp/dashboard-backup ${{ matrix.dashboard }} | ||
|
||
pulizie_di_primavera: | ||
needs: [preparation, backup_dashboard] | ||
runs-on: ubuntu-latest | ||
if: always() | ||
steps: | ||
- name: housekeeping | ||
uses: geekyeggo/delete-artifact@v2 | ||
with: | ||
name: | | ||
dashboard-backup | ||
- name: Bye ${{ github.actor }} | ||
if: always() | ||
run: | | ||
set +x | ||
if [ "${{ needs.preparation.result }}" == "success" ] && [ "${{ needs.backup_dashboard.result }}" == "success" ]; then | ||
echo -e "${{ env.YELLOW }} --------------------------------------------------------------------------------------------------------------------- ${{ env.NOCOLOUR }}" | ||
echo -e "${{ env.YELLOW }} *** It was a true pleasure to serve you ${{ github.actor }}, SEE YOU NEXT TIME! ${{ env.NOCOLOUR }}" | ||
echo -e "${{ env.YELLOW }} --------------------------------------------------------------------------------------------------------------------- ${{ env.NOCOLOUR }}" | ||
else | ||
echo -e "${{ env.RED }} --------------------------------------------------------------------------------------------------------------------- ${{ env.RED }}" | ||
echo -e "${{ env.RED }} *** Sorry ${{ github.actor }}, it seems there was an error this time: just fix it and COME BACK! ${{ env.RED }}" | ||
echo -e "${{ env.RED }} --------------------------------------------------------------------------------------------------------------------- ${{ env.RED }}" | ||
fi | ||
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
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
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
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
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
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