Updated Docker #71
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: Build and Publish Vanilla Docker Image to Nexus Artifactory | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'vanilla/**' | |
- .github/workflows/Vanilla.yml | |
jobs: | |
build-test-publish: | |
runs-on: ubuntu-latest | |
steps: | |
# Check out the repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Set up Docker | |
- name: Set up Docker Build | |
uses: docker/setup-buildx-action@v2 | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Execute Gradle build | |
env: | |
MAVEN_URL: ${{ secrets.MAVEN_URL }} | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
run: cd vanilla && gradle update | |
# Login to Nexus Artifactory | |
- name: Login to Nexus Docker Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.MAVEN_DOCKER_REPO }} # change this to your Nexus Registry URL | |
username: ${{ secrets.MAVEN_USERNAME }} | |
password: ${{ secrets.MAVEN_PASSWORD }} | |
# Build and push Docker image | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./vanilla # specifying the directory where your Dockerfile is | |
file: ./vanilla/Dockerfile # specifying the path to your Dockerfile | |
push: true | |
tags: ${{ secrets.MAVEN_DOCKER_REPO }}/vanilla:latest # change this to your image name | |
cleanup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Cleanup | |
run: | | |
gh extension install actions/gh-actions-cache | |
REPO=${{ github.repository }} | |
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" | |
echo "Fetching list of cache key" | |
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) | |
## Setting this to not fail the workflow while deleting cache keys. | |
set +e | |
echo "Deleting caches..." | |
for cacheKey in $cacheKeysForPR | |
do | |
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm | |
done | |
echo "Done" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |