Skip to content

Add deploy docker yml and changes #1

Add deploy docker yml and changes

Add deploy docker yml and changes #1

Workflow file for this run

name: Build and Publish Docker image
on:
push:
branches:
- main
jobs:
build-and-package:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: "17"
distribution: "temurin"
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-
- name: Build with Maven
run: mvn clean package
docker-build-and-push:
needs: build-and-package
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/shinjimc/spring_security_thymeleaf/spring_security_thymeleaf:latest
compress-and-upload:
needs: docker-build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Compress files
run: tar -czvf package.tar.gz ./Dockerfile ./.github/workflows/docker.yml
- name: Upload compressed file as artifact
uses: actions/upload-artifact@v2
with:
name: docker-package
path: package.tar.gz