Skip to content

main

main #62

Workflow file for this run

name: main
on:
push:
branches:
- '*'
schedule:
- cron: "0 23 * * 0" # weekly on Sunday evening
repository_dispatch:
jobs:
npm:
name: Update npm
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}
-
name: Setup npm
uses: actions/setup-node@v3
-
name: Checking updates for package-lock.json
run: npm update
-
name: add and commit changes for package-lock.json
uses: EndBug/add-and-commit@v9
with:
# The arguments for the `git add` command (see the paragraph below for more info)
# Default: '.'
add: 'package-lock.json'
# Additional arguments for the git commit command. The --message argument is already set by the message input.
# Default: ''
commit: --signoff
# Determines the way the action fills missing author name and email. Three options are available:
# - github_actor -> UserName <UserName@users.noreply.github.com>
# - user_info -> Your Display Name <your-actual@email.com>
# - github_actions -> github-actions <email associated with the github logo>
# Default: github_actor
default_author: github_actor
# The message for the commit.
# Default: 'Commit from GitHub Actions (name of the workflow)'
message: '[automatic] updated package-lock.json'
# The way the action should handle pathspec errors from the add and remove commands. Three options are available:
# - ignore -> errors will be logged but the step won't fail
# - exitImmediately -> the action will stop right away, and the step will fail
# - exitAtEnd -> the action will go on, every pathspec error will be logged at the end, the step will fail.
# Default: ignore
pathspec_error_handling: ignore
test:
name: Run tests
runs-on: ubuntu-latest
needs: npm
steps:
-
uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}
-
name: Setup npm
uses: actions/setup-node@v3
-
name: install project
run: npm install
-
name: Run tests
run: echo "TODO"
-
name: generate coverage report
run: echo "TODO" #coverage xml -i # creates coverage.xml
-
name: Upload coverage data to coveralls.io
run: echo "TODO" #coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
artifact:
name: Build artifacts
runs-on: ubuntu-latest
needs: test
if: github.ref_name == 'master'
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}
-
name: Setup npm
uses: actions/setup-node@v3
-
name: install project
run: npm install
-
name: Build artifacts dev
run: npm run build-dev
-
name: zip artifacts
run: pushd dist/misinfome-frontend-v2 && zip -r ../app-dev.zip . && popd
-
name: Build artifacts release
run: npm run build
-
name: zip artifacts
run: pushd dist/misinfome-frontend-v2 && zip -r ../app.zip . && popd
-
name: Get current date # for tagging the image, can go back in time if latest is problematic
id: date
run: echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
-
name: Release ${{ env.TODAY }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.TODAY }}
files: |
dist/app.zip
dist/app-dev.zip
-
name: delete release "latest"
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo
const { data: { id } } = await github.repos.getReleaseByTag({ owner, repo, tag: "latest" })
await github.repos.deleteRelease({ owner, repo, release_id: id })
-
name: Release "latest" again
uses: softprops/action-gh-release@v1
with:
tag_name: latest
files: |
dist/app.zip
dist/app-dev.zip
update-main-repo:
name: Update main repo
runs-on: ubuntu-latest
needs: artifact
if: github.ref_name == 'master' # already checked in docker job
permissions: write-all
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}
-
name: Get current sha
id: sha
run: echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
-
name: trigger main repo
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MISINFOME_GH_TOKEN }}
repository: MartinoMensio/MisinfoMe
event-type: 'Update: ${{ github.event.repository.name }}'
client-payload: '{ "submodule": "frontend-v2" , "repository": "${{ github.event.repository.name }}", "commit_sha": "${{ env.SHA }}" }'