diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index caaba64..72410db 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,6 @@ name: Publish on: + pull_request: release: types: [published] @@ -7,36 +8,33 @@ jobs: publish_to_dockerhub: name: Publish to Docker Hub runs-on: ubuntu-22.04 - if: ${{ startsWith(github.ref, 'refs/tags/v') }} steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to DockerHub - uses: docker/login-action@v1 + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Prepare tags - env: - DOCKER_IMAGE: reactnativecommunity/react-native-android - STABLE_MAJOR: 1 - id: tags - run: | - VERSION=${GITHUB_REF#refs/tags/v} - MAJOR=$(echo $VERSION | cut -d'.' -f 1) - TAGS="$DOCKER_IMAGE:$VERSION,$DOCKER_IMAGE:$MAJOR" - if [[ $MAJOR == $STABLE_MAJOR ]]; then - TAGS="$TAGS,$DOCKER_IMAGE:latest" - fi - echo ::set-output name=tags::${TAGS} - + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + flavor: | + latest=false + images: | + reactnativecommunity/react-native-android + tags: | + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}} - name: Build & publish to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.tags.outputs.tags }}