diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index a3556bd1..62ee4c47 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -30,19 +30,28 @@ jobs: docker: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v2.x + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - name: Set variables + id: prep run: | - echo "REPOSITORY=$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV - - name: Build and push Docker image - uses: docker/build-push-action@v2.5.0 + DOCKER_IMAGE=server + REPOSITORY="$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')" + + TAGS="ghcr.io/${REPOSITORY}/${DOCKER_IMAGE}:${GITHUB_SHA}" + if [ "${{ github.ref }}" = "refs/heads/master" ]; then + TAGS="$TAGS,ghcr.io/${REPOSITORY}/${DOCKER_IMAGE}:latest,ghcr.io/${REPOSITORY}/${DOCKER_IMAGE}:master" + fi + + echo ::set-output name=tags::${TAGS} + - name: Log in to GitHub Docker Registry + uses: docker/login-action@v1 with: + registry: ghcr.io username: ${{ github.actor }} - password: ${{ github.token }} - registry: docker.pkg.github.com - repository: ${{ env.REPOSITORY }}/server - tag_with_sha: true - tag_with_ref: true \ No newline at end of file + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build container image + uses: docker/build-push-action@v2 + with: + push: true + tags: ${{ steps.prep.outputs.tags }} \ No newline at end of file