Build docker images #199
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 docker images | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 3 * * *' | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - packages/alpine-node-nginx/** | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| versions: [ | |
| { node: '20.20.0', alpine: '3.23', image: node, dockerfile: Dockerfile, tag: '20.20.0' }, | |
| { node: '22.22.0', alpine: '3.23', image: node, dockerfile: Dockerfile, tag: '22.22.0' }, | |
| { node: '24.13.0', alpine: '3.23', image: node, dockerfile: Dockerfile, tag: '24.13.0' }, | |
| { node: '20.20.0', alpine: '3.23', image: node, dockerfile: Dockerfile-slim, tag: '20.20.0-slim' }, | |
| { node: '22.22.0', alpine: '3.23', image: node, dockerfile: Dockerfile-slim, tag: '22.22.0-slim' }, | |
| { node: '24.13.0', alpine: '3.23', image: node, dockerfile: Dockerfile-slim, tag: '24.13.0-slim' }, | |
| ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get git short SHA | |
| id: git_info | |
| run: | | |
| echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| echo "is_master=${{ github.ref_name == 'master' }}" >> $GITHUB_OUTPUT | |
| - name: Determine tag | |
| id: tag_info | |
| run: | | |
| if [ "${{ steps.git_info.outputs.is_master }}" = "true" ]; then | |
| echo "final_tag=${{ matrix.versions.tag }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "final_tag=${{ matrix.versions.tag }}-${{ steps.git_info.outputs.short_sha }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
| - name: Build and push Docker images | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: packages/alpine-node-nginx/ | |
| file: packages/alpine-node-nginx/${{ matrix.versions.dockerfile }} | |
| push: true | |
| build-args: | | |
| NODE_VERSION=${{ matrix.versions.node }} | |
| ALPINE_VERSION=${{ matrix.versions.alpine }} | |
| NODE_BASE_IMAGE=${{ matrix.versions.image }} | |
| tags: alfabankui/arui-scripts:${{ steps.tag_info.outputs.final_tag }} |