refactor(#33): removed unused code #82
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Build and Deploy | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
branches: [ "main" ] | |
env: | |
DOCKER_IMAGE_NAME: openeo-job-registry-elastic-api | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- run: npm install | |
- run: npm run test:cov | |
- run: npm run build | |
release: | |
needs: build | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
- run: npm install | |
- run: npm run release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- id: version | |
run: | | |
version=$(npm pkg get version | tr -d '"') | |
echo "docker_version=${version}" >> $GITHUB_OUTPUT | |
outputs: | |
docker_version: ${{ steps.version.outputs.docker_version }} | |
deploy: | |
needs: release | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
- name: Update package.json | |
id: version | |
run: | | |
sed -i "s/0.0.0-semver/${{needs.release.outputs.docker_version}}/g" package.json | |
- run: npm install | |
- name: Login to Docker repository | |
uses: docker/login-action@v2 | |
with: | |
timeout_minutes: 5 | |
max_attempts: 3 | |
registry: ${{ secrets.DOCKER_ARTIFACTORY }} | |
username: ${{ secrets.ARTIFACTORY_USERNAME }} | |
password: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
- name: Build image | |
run: docker build -t $DOCKER_IMAGE_NAME . | |
- name: Tag image | |
run: docker tag $DOCKER_IMAGE_NAME ${{ secrets.DOCKER_ARTIFACTORY }}/$DOCKER_IMAGE_NAME:${{needs.release.outputs.docker_version}} && docker tag $DOCKER_IMAGE_NAME ${{ secrets.DOCKER_ARTIFACTORY }}/$DOCKER_IMAGE_NAME:latest | |
- name: Push image | |
run: docker push ${{ secrets.DOCKER_ARTIFACTORY }}/$DOCKER_IMAGE_NAME:${{needs.release.outputs.docker_version}} && docker push ${{ secrets.DOCKER_ARTIFACTORY }}/$DOCKER_IMAGE_NAME:latest | |