|
| 1 | +name: Node.js with Python and GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - beta |
| 8 | + - travisci |
| 9 | + tags: |
| 10 | + - '*' |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - master |
| 14 | + - beta |
| 15 | + - travisci |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + |
| 24 | + - name: Set up Node.js |
| 25 | + uses: actions/setup-node@v2 |
| 26 | + with: |
| 27 | + node-version: 16 |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: npm install |
| 31 | + |
| 32 | + - name: Install python dependencies |
| 33 | + run: | |
| 34 | + python -m pip install --upgrade pip |
| 35 | + pip install configparser pandas pillow |
| 36 | +
|
| 37 | + - name: Cache node modules |
| 38 | + uses: actions/cache@v2 |
| 39 | + with: |
| 40 | + path: ~/.npm |
| 41 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 42 | + restore-keys: | |
| 43 | + ${{ runner.os }}-node- |
| 44 | + |
| 45 | + - name: Cache python packages |
| 46 | + uses: actions/cache@v2 |
| 47 | + with: |
| 48 | + path: ~/.cache/pip |
| 49 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 50 | + restore-keys: | |
| 51 | + ${{ runner.os }}-pip- |
| 52 | +
|
| 53 | + - name: Run make.sh |
| 54 | + run: ./bin/make.sh --install-channel=$GITHUB_REF_NAME --install --cache |
| 55 | + |
| 56 | + - name: Test |
| 57 | + run: TYP='csv gpx' ./bin/make.sh --build=hasCache --run --build="$TYP" --build="CNX_GATSO_FR" --release-prefix="FR:gatso:" |
| 58 | + |
| 59 | + - name: Build for release GATSO EU |
| 60 | + run: TYP='csv gpx' ./bin/make.sh --build=hasCache --run --build="$TYP" --build="CNX_GATSO_FR CNX_GATSO_EU" --release-prefix="EU:gatso:" |
| 61 | + |
| 62 | + - name: Build for release FUEL FR |
| 63 | + run: TYP='csv gpx' ./bin/make.sh --build=hasCache --run --build="$TYP" --build="CNX_FUEL_FR" --release-prefix="FR:fuel:" |
| 64 | + |
| 65 | + - name: Build for release FULL FR |
| 66 | + run: TYP='csv gpx' ./bin/make.sh --build=hasCache --run --build="$TYP" --build="CNX_GATSO_FR CNX_FUEL_FR" --release-prefix="FR:gatso-fuel:" |
| 67 | + |
| 68 | + - name: Build image |
| 69 | + run: ./bin/make.sh --build=hasCache --run --image |
| 70 | + |
| 71 | + - name: Deploy |
| 72 | + |
| 73 | + with: |
| 74 | + branch: gh-pages |
| 75 | + folder: ./RELEASES |
| 76 | + |
| 77 | + - name: Untag |
| 78 | + run: ./bin/make.sh --uninstall |
| 79 | + |
| 80 | + - name: Create Git tag |
| 81 | + run: | |
| 82 | + git config --local user.name "$USER_NAME" |
| 83 | + git config --local user.email "$USER_EMAIL" |
| 84 | + git tag --force "${{ github.ref }}" ${{ github.sha }} |
| 85 | +
|
| 86 | +- name: Publish to Github Releases (tag) |
| 87 | + uses: actions/github-script@v3 |
| 88 | + with: |
| 89 | + script: | |
| 90 | + const release = await github.releases.createRelease({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + tag_name: context.ref, |
| 94 | + name: context.ref, |
| 95 | + draft: false, |
| 96 | + prerelease: context.ref.includes('beta') || context.ref.includes('travisci') |
| 97 | + }) |
| 98 | + const uploads = await github.releases.uploadAssets( |
| 99 | + { |
| 100 | + upload_url: release.upload_url, |
| 101 | + headers: { |
| 102 | + 'Content-Type': 'application/zip', |
| 103 | + 'Authorization': `Bearer ${process.env.GITHUB_TOKEN}` |
| 104 | + }, |
| 105 | + asset_path: './RELEASES/*.zip', |
| 106 | + asset_name: 'all_files.zip', |
| 107 | + asset_content_type: 'application/zip' |
| 108 | + }, |
| 109 | + fs.readFileSync('./RELEASES/all_files.zip') |
| 110 | + ) |
| 111 | + console.log(`Created release ${release.name} with asset ${uploads.assets[0].name} (size: ${uploads.assets[0].size})`) |
| 112 | + const uploads1 = await github.releases.uploadAssets( |
| 113 | + { |
| 114 | + upload_url: release.upload_url, |
| 115 | + headers: { |
| 116 | + 'Content-Type': 'application/zip', |
| 117 | + 'Authorization': `Bearer ${process.env.GITHUB_TOKEN}` |
| 118 | + }, |
| 119 | + asset_path: './RELEASES/*.iso.zip', |
| 120 | + asset_name: 'all_files.zip', |
| 121 | + asset_content_type: 'application/zip' |
| 122 | + }, |
| 123 | + fs.readFileSync('./RELEASES/*.iso.zip') |
| 124 | + ) |
| 125 | + console.log(`Created release ${release.name} with asset ${uploads1.assets[0].name} (size: ${uploads1.assets[0].size})`) |
| 126 | +
|
| 127 | + - name: Publish to Github Releases (branch) |
| 128 | + uses: actions/github-script@v3 |
| 129 | + with: |
| 130 | + script: | |
| 131 | + const release = await github.rest.repos.createRelease({ |
| 132 | + owner: context.repo.owner, |
| 133 | + repo: context.repo.repo, |
| 134 | + name: "${{ github.ref }}", |
| 135 | + body: "", |
| 136 | + draft: false, |
| 137 | + prerelease: context.ref.includes('beta') || context.ref.includes('travisci') |
| 138 | + }) |
| 139 | + const uploads = await github.rest.repos.uploadReleaseAsset({ |
| 140 | + owner: context.repo.owner, |
| 141 | + repo: context.repo.repo, |
| 142 | + release_id: release.data.id, |
| 143 | + name: 'all_files.zip', |
| 144 | + path: './RELEASES/all_files.zip' |
| 145 | + }) |
| 146 | + console.log(`Created release "${release.data.name}" with asset "${uploads.data.name}" (size: ${uploads.data.size})`) |
| 147 | + const uploads1 = await github.rest.repos.uploadReleaseAsset({ |
| 148 | + owner: context.repo.owner, |
| 149 | + repo: context.repo.repo, |
| 150 | + release_id: release.data.id, |
| 151 | + name: 'all_files.iso.zip', |
| 152 | + path: './RELEASES/*.iso.zip' |
| 153 | + }) |
| 154 | + console.log(`Created release "${release.data.name}" with asset "${uploads1.data.name}" (size: ${uploads1.data.size})`) |
| 155 | +
|
| 156 | + - name: Publish to GitHub Pages |
| 157 | + uses: peaceiris/actions-gh-pages@v3 |
| 158 | + with: |
| 159 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + publish_dir: ./RELEASES |
| 161 | + |
0 commit comments