stable #36
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
name: stable | |
on: | |
push: | |
branches: | |
- 'master' | |
workflow_dispatch: | |
schedule: | |
# one scheduled build on the first day of every month at 3:42 | |
- cron: '47 3 1 * *' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Run ShellCheck | |
uses: ludeeus/action-shellcheck@master | |
with: | |
scandir: './snap/hooks' | |
- name: Check spelling | |
uses: crate-ci/typos@master | |
with: | |
files: ./README* ./snap/*.yaml ./snap/hooks/* | |
isolated: true | |
trigger: | |
needs: [lint] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup git | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git remote add deploy git+ssh://[email protected]/~vergo/+git/vnstat-snap | |
- name: Setup ssh | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Setup git.launchpad.net as known host | |
env: | |
GIT_LAUNCHPAD_HOST: ${{ secrets.GIT_LAUNCHPAD_NET_SSH }} | |
run: echo "$GIT_LAUNCHPAD_HOST" >>~/.ssh/known_hosts | |
- name: Discover latest vnStat release tag | |
run: | | |
echo "VNSTAT_RELEASE_TAG=$(git ls-remote --refs --tags --sort=version:refname https://github.com/vergoh/vnstat | grep "refs/tags/v" | tail -n 1 | cut -d/ -f3)" >>$GITHUB_ENV | |
- name: Discover current snap commit | |
run: | | |
echo "SNAP_COMMIT=$(git rev-parse --short=1 "$GITHUB_SHA")" >>$GITHUB_ENV | |
- name: Setup build details for stable | |
shell: bash | |
run: | | |
git checkout -b stable | |
sed -i -e "s/source-branch:.*/source-tag: $VNSTAT_RELEASE_TAG/g" snap/snapcraft.yaml | |
sed -i -e "s:--tags --long:--tags:g" snap/snapcraft.yaml | |
sed -i -e "s/::g')\"\$/::g')-$SNAP_COMMIT\"/g" snap/snapcraft.yaml | |
echo "# timestamp: $(date +"%F %X")" >>snap/snapcraft.yaml | |
git diff | |
git commit -a -m "GitHub $GITHUB_REPOSITORY $GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER" | |
- name: Build test | |
uses: snapcore/action-build@v1 | |
id: snapcraft | |
- name: Install test | |
run: | | |
sudo snap install --dangerous ${{ steps.snapcraft.outputs.snap }} | |
vnstat --version | |
- name: Push changes | |
run: | | |
git push deploy stable --force |