diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 98d8cc8..06dca54 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,30 +1,46 @@ +name: Docker Build and Push + on: - push: - branches-ignore: - - '**' - tags: - - 'v*' + release: + types: [created] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: - build: + build-and-push: runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: - - name: Check out the repository - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 + - name: Log in to the Container registry + uses: docker/login-action@v2 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/build-push-action@v2 + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 with: context: . push: true - tags: | - ghcr.io/mii443/rs-easy-p2p/signaling-server:{{version}} - ghcr.io/mii443/rs-easy-p2p/signaling-server:latest + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file