Update action versions in CICD #56
This file contains hidden or 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: Build | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| VERSION: ${{ steps.set-version.outputs.VERSION }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 18 | |
| - run: npm ci | |
| - name: Lint | |
| run: npm run lint | |
| - name: Build | |
| run: npm run build | |
| - name: Print version | |
| run: node lib/index.js --version | |
| - name: Set VERSION variable | |
| id: set-version | |
| run: echo "VERSION=$(node lib/index.js --version)" >> $GITHUB_OUTPUT | |
| valid_tag: | |
| needs: [build] | |
| if: github.ref_type == 'tag' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Print version | |
| run: echo "${{ needs.build.outputs.VERSION }}" | |
| - name: Check that the tag follows semantic versioning with "v" prefix | |
| run: echo ${{ github.ref_name }} | egrep '^v[0-9]+\.[0-9]+\.[0-9]+\S*$' | |
| - name: Check that version matches git tag | |
| run: test "v${{ needs.build.outputs.VERSION }}" == "${{ github.ref_name }}" | |
| docker_build_and_push_to_gitlab: | |
| needs: [build, valid_tag] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Login to GitLab Container Registry | |
| run: echo ${{ secrets.REGISTRY_PASSWORD }} | docker login -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin ${{ vars.REGISTRY_URL }} | |
| - name: Build and tag Docker image | |
| run: docker build -t ${{ vars.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/packages/surface-calculator:latest . | |
| - name: Push Docker image to GitLab Container Registry | |
| run: docker push ${{ vars.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/packages/surface-calculator:latest |