name: Docker Image CI on: push: tags: - '*' # Trigger on any tag branches: - main # Trigger on push to main branch - beta # Trigger on push to beta branch paths-ignore: - '**.md' permissions: packages: write jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Determine Image Tag id: image_tag run: | if [ "${{ github.ref_type }}" == "tag" ]; then IMAGE_NAME="ghcr.io/chocomeow/vocard:${{ github.ref_name }}" elif [ "${{ github.ref }}" == "refs/heads/beta" ]; then IMAGE_NAME="ghcr.io/chocomeow/vocard:beta" elif [ "${{ github.ref }}" == "refs/heads/main" ]; then IMAGE_NAME="ghcr.io/chocomeow/vocard:latest" else echo "Error: Triggered on an unexpected ref: ${{ github.ref }}" exit 1 fi echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV echo "Set image name to: ${IMAGE_NAME}" - name: Build the Docker image run: | echo "Building image: ${{ env.IMAGE_NAME }}" docker build . --file Dockerfile --tag ${{ env.IMAGE_NAME }} - name: Log in to GitHub Docker Registry env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Push the Docker image run: | echo "Pushing image: ${{ env.IMAGE_NAME }}" docker push ${{ env.IMAGE_NAME }} echo "Successfully pushed ${{ env.IMAGE_NAME }}"