Skip to content

Update Dockerfile

Update Dockerfile #6

Workflow file for this run

name: CI/CD pipeline for successful merge
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v4
with:
java-version: '21'
cache: 'maven'
distribution: 'corretto'
- name: Create settings.xml
run: |
SETTINGS_XML_PATH="${GITHUB_WORKSPACE}/settings.xml"
cat << EOF > ${SETTINGS_XML_PATH}
<settings>
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/apiprotector/API-Protector</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${{ secrets.GH_PACKAGES_USER }}</username>
<password>${{ secrets.GH_PACKAGES_PAT }}</password>
</server>
</servers>
</settings>
EOF
env:
GH_PACKAGES_USER: ${{ secrets.GH_PACKAGES_USER }}
GH_PACKAGES_PAT: ${{ secrets.GH_PACKAGES_PAT }}
- name: Add executable permissions
run: chmod a+x mvnw
- name: Maven install dependencies
run: |
SETTINGS_XML_PATH="${GITHUB_WORKSPACE}/settings.xml"
./mvnw clean install package -Dmaven.test.skip=true --settings ${SETTINGS_XML_PATH}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker Build and Push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/apiprotector:${{ github.sha }}
- name: Update CICD-VPS
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'Dawid Jabłoński'
git config --global user.email 'xederro@gmail.com'
git config --unset-all http.https://github.com/.extraheader
rm -rf .git
mkdir cicd
cd cicd
git clone "https://x-access-token:${{ secrets.TOKEN_VPS_REPO }}@github.com/xederro/CICD-VPS.git" --depth=1
cd CICD-VPS
sed -i 's|piachsecki/apiprotector:[0-9a-f]\{40\}|piachsecki/apiprotector:${{ github.sha }}|g' docker-stack.yml
git add .
git commit -m"API Protector Update: $(date)"
git push