name: Docker Image CI on: push: branches: - main env: REPO: ${{ github.repository }} jobs: npm-push: runs-on: ubuntu-22.04 permissions: # Give the default GITHUB_TOKEN write permission to commit and push the # added or changed files to the repository. contents: write steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 registry-url: ${{ vars.NPM_REGISTRY }} token: ${{ secrets.NPM_TOKEN }} - name: Install npm dependencies run: | npm install -g pnpm pnpm install - run: pnpm build - name: Increment package version and push env: GITHUB_TOKEN: ${{ github.token }} run: | git config --global user.name 'bot-build' git config --global user.email 'techbots+build@gmetri.com' export N=`node -p require\(\'./package.json\'\).name` && echo $N pnpm version patch --message "v%s: $N [CI SKIP]" npm publish git push origin git push --tags origin container-push: runs-on: ubuntu-22.04 steps: - id: get-id name: Get a unique tag for this build run: | SHA=${{ github.sha }}; BRANCH_NAME=${{ github.base_ref || github.ref_name }}; BUILD_ID=$BRANCH_NAME-${SHA:0:8}; DOCKER_IMAGE=${{ vars.docker_repo2_registry }}/$REPO:$BUILD_ID; echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT"; echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT"; - name: Print build id and image name run: | echo "BUILD_ID: ${{ steps.get-id.outputs.BUILD_ID }}"; echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}"; - uses: actions/checkout@v4 - name: Login to docker container registry uses: docker/login-action@v3 with: registry: ${{ vars.docker_repo2_registry }} username: ${{ vars.docker_repo2_username }} password: ${{ vars.docker_repo2_password }} - name: Build the container image run: | docker build \ --build-arg PUBLIC_BUILD_VERSION=${{ steps.get-id.outputs.BUILD_ID }} \ --file fab/d/actions-build.Dockerfile \ --tag ${{ steps.get-id.outputs.DOCKER_IMAGE }} \ .; - name: Container details run: | IMAGE_SIZE=`docker inspect -f "{{ .Size }}" ${{ steps.get-id.outputs.DOCKER_IMAGE }} | numfmt --to=si`; echo "$IMAGE_SIZE container ${{ steps.get-id.outputs.DOCKER_IMAGE }}"; - name: Push the container image run: docker push ${{ steps.get-id.outputs.DOCKER_IMAGE }}