Create a release #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: [ master, main, develop ] | |
| pull_request: | |
| branches: [ master, main, develop ] | |
| workflow_dispatch: # Allow manual triggering | |
| env: | |
| DOCKER_IMAGE: webcuisine/gitlab-ci-react-native-android | |
| TAG_VERSION: android-34.0.0 | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=raw,value=${{ env.TAG_VERSION }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Update Docker Hub description | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' | |
| continue-on-error: true | |
| uses: peter-evans/dockerhub-description@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| repository: ${{ env.DOCKER_IMAGE }} | |
| readme-filepath: ./README.md | |
| - name: Generate release tag | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' | |
| id: tag | |
| run: | | |
| # Generate a version tag based on date and commit | |
| TAG="v$(date +'%Y.%m.%d')-${{ env.TAG_VERSION }}" | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "Generated tag: $TAG" | |
| - name: Create GitHub Release | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Create release using GitHub CLI | |
| gh release create ${{ steps.tag.outputs.tag }} \ | |
| --title "Docker Image ${{ steps.tag.outputs.tag }}" \ | |
| --notes "## 🐳 Docker Image Release | |
| **Docker Image**: \`${{ env.DOCKER_IMAGE }}:latest\` | |
| **Version Tag**: \`${{ env.DOCKER_IMAGE }}:${{ env.TAG_VERSION }}\` | |
| ### 📦 What's Included | |
| - Ubuntu 22.04 LTS | |
| - Android SDK 34.0.0 with command line tools | |
| - Java 17 (OpenJDK) | |
| - Node.js 18 LTS | |
| - Gradle 8.5 | |
| - Yarn latest | |
| - Fastlane latest | |
| ### 🚀 Usage | |
| \`\`\`bash | |
| # Use in GitLab CI | |
| image: ${{ env.DOCKER_IMAGE }}:latest | |
| # Or use the version tag | |
| image: ${{ env.DOCKER_IMAGE }}:${{ env.TAG_VERSION }} | |
| \`\`\` | |
| ### 🔗 Links | |
| - [Docker Hub Repository](https://hub.docker.com/r/${{ env.DOCKER_IMAGE }}) | |
| - [GitHub Repository](https://github.com/${{ github.repository }}) | |
| **Commit**: ${{ github.sha }} | |
| **Build Date**: $(date -u +'%Y-%m-%d %H:%M:%S UTC')" |