|
1 | 1 | name: Publish
|
2 | 2 | on:
|
| 3 | + pull_request: |
3 | 4 | release:
|
4 | 5 | types: [published]
|
5 | 6 |
|
6 | 7 | jobs:
|
7 | 8 | publish_to_dockerhub:
|
8 | 9 | name: Publish to Docker Hub
|
9 | 10 | runs-on: ubuntu-22.04
|
10 |
| - if: ${{ startsWith(github.ref, 'refs/tags/v') }} |
11 | 11 | steps:
|
12 | 12 | - name: Check out the repo
|
13 |
| - uses: actions/checkout@v2 |
| 13 | + uses: actions/checkout@v3 |
14 | 14 |
|
15 | 15 | - name: Set up Docker Buildx
|
16 |
| - uses: docker/setup-buildx-action@v1 |
| 16 | + uses: docker/setup-buildx-action@v2 |
17 | 17 |
|
18 | 18 | - name: Login to DockerHub
|
19 |
| - uses: docker/login-action@v1 |
| 19 | + if: github.event_name != 'pull_request' |
| 20 | + uses: docker/login-action@v2 |
20 | 21 | with:
|
21 | 22 | username: ${{ secrets.DOCKER_USERNAME }}
|
22 | 23 | password: ${{ secrets.DOCKER_PASSWORD }}
|
23 |
| - |
24 |
| - - name: Prepare tags |
25 |
| - env: |
26 |
| - DOCKER_IMAGE: reactnativecommunity/react-native-android |
27 |
| - STABLE_MAJOR: 1 |
28 |
| - id: tags |
29 |
| - run: | |
30 |
| - VERSION=${GITHUB_REF#refs/tags/v} |
31 |
| - MAJOR=$(echo $VERSION | cut -d'.' -f 1) |
32 |
| - TAGS="$DOCKER_IMAGE:$VERSION,$DOCKER_IMAGE:$MAJOR" |
33 |
| - if [[ $MAJOR == $STABLE_MAJOR ]]; then |
34 |
| - TAGS="$TAGS,$DOCKER_IMAGE:latest" |
35 |
| - fi |
36 |
| - echo ::set-output name=tags::${TAGS} |
37 |
| -
|
| 24 | + - name: Docker meta |
| 25 | + id: meta |
| 26 | + uses: docker/metadata-action@v4 |
| 27 | + with: |
| 28 | + flavor: | |
| 29 | + latest=false |
| 30 | + images: | |
| 31 | + reactnativecommunity/react-native-android |
| 32 | + tags: | |
| 33 | + type=ref,event=pr |
| 34 | + type=semver,pattern={{version}} |
| 35 | + type=semver,pattern={{major}} |
38 | 36 | - name: Build & publish to Docker Hub
|
39 |
| - uses: docker/build-push-action@v2 |
| 37 | + uses: docker/build-push-action@v4 |
40 | 38 | with:
|
41 |
| - push: true |
| 39 | + push: ${{ github.event_name != 'pull_request' }} |
42 | 40 | tags: ${{ steps.tags.outputs.tags }}
|
0 commit comments