CI #6997
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: CI | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
schedule: | |
- cron: "0 */1 * * *" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
outputs: | |
update_available: ${{ steps.update_available.outputs.update_status }} | |
steps: | |
- id: current_repo | |
uses: pozetroninc/github-action-get-latest-release@master | |
with: | |
repository: ${{ github.repository }} | |
- uses: actions/checkout@master | |
with: | |
fetch-depth: 0 | |
repository: lovasoa/ophirofox | |
path: './ophirofox' | |
- name: "Get latest ophirofox version number" | |
working-directory: ophirofox | |
run: | | |
echo OPHIROFOX_VERSION_RAW=$(git describe --tags `git rev-list --tags --max-count=1`) >> $GITHUB_ENV | |
echo OPHIROFOX_VERSION=$(cut -c2- <<< $(git describe --tags `git rev-list --tags --max-count=1`)) >> $GITHUB_ENV | |
- id: update_available | |
run: | | |
echo CURRENT REPO RELEASE : ${{ steps.current_repo.outputs.release }} | |
echo OPHIROFOX REPO RELEASE : ${{ env.OPHIROFOX_VERSION_RAW }} | |
if [[ ${{ steps.current_repo.outputs.release }} == ${{ env.OPHIROFOX_VERSION_RAW }} ]]; then | |
echo "No release available" | |
update_status=0 | |
echo "update_status=false" >> $GITHUB_OUTPUT | |
else | |
echo "New release available" | |
update_status=1 | |
echo "update_status=true" >> $GITHUB_OUTPUT | |
fi | |
build: | |
runs-on: ubuntu-latest | |
needs: check-version | |
if: ${{ needs.check-version.outputs.update_available == 'true' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/checkout@master | |
with: | |
fetch-depth: 0 | |
repository: lovasoa/ophirofox | |
path: './ophirofox' | |
- name: "Get latest ophirofox version number" | |
working-directory: ophirofox | |
run: | | |
echo OPHIROFOX_VERSION=$(cut -c2- <<< $(git describe --tags `git rev-list --tags --max-count=1`)) >> $GITHUB_ENV | |
- name: Copy generate-userscript.sh inside ophirofox dir | |
run: cp ./generate-userscript.sh ./ophirofox/generate-userscript.sh | |
- name: Grant execution rights to generate-userscript.sh | |
working-directory: ophirofox | |
run: chmod +x ./generate-userscript.sh | |
- name: Run generate-userscript.sh | |
working-directory: ophirofox | |
run: ./generate-userscript.sh ${{ env.OPHIROFOX_VERSION }} | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install jsbeautifier via pip | |
working-directory: ophirofox | |
run: pip install jsbeautifier | |
- name: Beautify userscript | |
working-directory: ophirofox | |
run: js-beautify ophirofox.user.js >> ophirofox-pretty.user.js && mv ophirofox-pretty.user.js ophirofox.user.js | |
- name: Get ophirofox changelog | |
working-directory: ophirofox | |
run: git log -1 --pretty=%B | tee /tmp/changelog.txt | |
- name: Push to main | |
run: | | |
cp ./ophirofox/ophirofox.user.js . | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add ophirofox.user.js | |
git commit -m "Release from Ophirofox v${{ env.OPHIROFOX_VERSION }}" | |
git push | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ env.OPHIROFOX_VERSION }} | |
name: Release ${{ env.OPHIROFOX_VERSION }} | |
draft: false | |
prerelease: false | |
body_path: /tmp/changelog.txt | |
files: | | |
./ophirofox/ophirofox.user.js | |
/tmp/changelog.txt | |