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: Node.js with Python and GitHub Pages | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- beta | ||
- travisci | ||
- test_deploy | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- master | ||
- beta | ||
- travisci | ||
- test_deploy | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Install python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install configparser pandas pillow | ||
- name: Cache node modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Cache python packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Run make.sh | ||
run: ./bin/make.sh --install-channel=$GITHUB_REF_NAME --install --cache | ||
- name: Test | ||
run: TYP='csv gpx' ./bin/make.sh --build=hasCache --run --build="$TYP" --build="CNX_GATSO_FR" --release-prefix="FR:gatso:" | ||
- name: Build for release GATSO EU | ||
run: TYP='csv gpx' ./bin/make.sh --build=hasCache --run --build="$TYP" --build="CNX_GATSO_FR CNX_GATSO_EU" --release-prefix="EU:gatso:" | ||
- name: Build for release FUEL FR | ||
run: TYP='csv gpx' ./bin/make.sh --build=hasCache --run --build="$TYP" --build="CNX_FUEL_FR" --release-prefix="FR:fuel:" | ||
- name: Build for release FULL FR | ||
run: TYP='csv gpx' ./bin/make.sh --build=hasCache --run --build="$TYP" --build="CNX_GATSO_FR CNX_FUEL_FR" --release-prefix="FR:gatso-fuel:" | ||
- name: Build image | ||
run: ./bin/make.sh --build=hasCache --run --image | ||
- name: Deploy | ||
uses: JamesIves/[email protected] | ||
with: | ||
branch: gh-pages | ||
folder: ./RELEASES | ||
- name: Untag | ||
run: ./bin/make.sh --uninstall | ||
- name: Create Git tag | ||
run: | | ||
git config --local user.name "$USER_NAME" | ||
git config --local user.email "$USER_EMAIL" | ||
git tag --force "${{ github.ref }}" ${{ github.sha }} | ||
- name: Publish to Github Releases (tag) | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
const release = await github.releases.createRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag_name: context.ref, | ||
name: context.ref, | ||
draft: false, | ||
prerelease: context.ref.includes('beta') || context.ref.includes('travisci') | ||
}) | ||
const uploads = await github.releases.uploadAssets( | ||
{ | ||
upload_url: release.upload_url, | ||
headers: { | ||
'Content-Type': 'application/zip', | ||
'Authorization': `Bearer ${process.env.GITHUB_TOKEN}` | ||
}, | ||
asset_path: './RELEASES/*.zip', | ||
asset_name: 'all_files.zip', | ||
asset_content_type: 'application/zip' | ||
}, | ||
fs.readFileSync('./RELEASES/all_files.zip') | ||
) | ||
console.log(`Created release ${release.name} with asset ${uploads.assets[0].name} (size: ${uploads.assets[0].size})`) | ||
const uploads1 = await github.releases.uploadAssets( | ||
{ | ||
upload_url: release.upload_url, | ||
headers: { | ||
'Content-Type': 'application/zip', | ||
'Authorization': `Bearer ${process.env.GITHUB_TOKEN}` | ||
}, | ||
asset_path: './RELEASES/*.iso.zip', | ||
asset_name: 'all_files.zip', | ||
asset_content_type: 'application/zip' | ||
}, | ||
fs.readFileSync('./RELEASES/*.iso.zip') | ||
) | ||
console.log(`Created release ${release.name} with asset ${uploads1.assets[0].name} (size: ${uploads1.assets[0].size})`) | ||
- name: Publish to Github Releases (branch) | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
const release = await github.rest.repos.createRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: "${{ github.ref }}", | ||
body: "", | ||
draft: false, | ||
prerelease: context.ref.includes('beta') || context.ref.includes('travisci') | ||
}) | ||
const uploads = await github.rest.repos.uploadReleaseAsset({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: release.data.id, | ||
name: 'all_files.zip', | ||
path: './RELEASES/all_files.zip' | ||
}) | ||
console.log(`Created release "${release.data.name}" with asset "${uploads.data.name}" (size: ${uploads.data.size})`) | ||
const uploads1 = await github.rest.repos.uploadReleaseAsset({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: release.data.id, | ||
name: 'all_files.iso.zip', | ||
path: './RELEASES/*.iso.zip' | ||
}) | ||
console.log(`Created release "${release.data.name}" with asset "${uploads1.data.name}" (size: ${uploads1.data.size})`) | ||
- name: Publish to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./RELEASES | ||