Added vidoe for requesting crypto #34
This file contains 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: Docker Build and Push | |
on: | |
pull_request: | |
branches: | |
- main # Build on pull requests to the main branch | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
steps: | |
# Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Set up JDK 17 for Gradle | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
# Cache Gradle dependencies to speed up the build | |
- name: Cache Gradle dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# Build the JAR file using Gradle | |
- name: Build the application JAR | |
run: ./gradlew buildFatJar | |
# Build the Docker image | |
- name: Build Docker image | |
run: docker build -t ${DOCKER_HUB_USERNAME}/smartpesa:latest . | |
# Log in to Docker Hub | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
# Push Docker image to Docker Hub | |
- name: Push Docker image to Docker Hub | |
run: docker push ${DOCKER_HUB_USERNAME}/smartpesa:latest | |
# Clean up unused Docker resources | |
- name: Clean up | |
run: | | |
docker system prune -f |