Add Docker CI workflow for vX.Y tags #2
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
| # .github/workflows/docker-ci-demo.yml | |
| name: Docker CI Demo | |
| on: | |
| push: | |
| branches: | |
| - 'master' | |
| - 'main' | |
| tags: | |
| - 'v*.*' | |
| - 'v*.*.*' | |
| env: | |
| DOCKER_IMAGE_NAME: msj6785/nodejs-ci | |
| jobs: | |
| push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract Docker metadata (tags and labels) | |
| id: docker_meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=tag | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} | |
| - name: Set up QEMU for multi-platform builds | |
| uses: docker/setup-qemu-action@v3 # 최신 버전 사용 권장 | |
| - 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_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
| - name: Build and push Docker Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.docker_meta.outputs.tags }} | |
| labels: ${{ steps.docker_meta.outputs.labels }} |