add pipline #1
@@ -0,0 +1,78 @@
|
||||
name: Build docker image and push to test
|
||||
run-name: Build Docker and Push
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build_image_push:
|
||||
runs-on: gitea_runner
|
||||
name: Build binaries, Build docker image, Apply on test
|
||||
|
||||
env:
|
||||
REGISTRY_ADDRESS: registry.ma-al.pl
|
||||
DOCKER_APP_NAME: cl-project
|
||||
MAAL_REGISTRY_USER: ${{ secrets.MAAL_REGISTRY_USER }}
|
||||
MAAL_REGISTRY_PASSWORD: ${{ secrets.MAAL_REGISTRY_PASSWORD }}
|
||||
MAAL_SSH_PRIVATE_KEY: ${{ secrets.MAAL_SSH_PRIVATE_KEY }}
|
||||
|
||||
steps:
|
||||
- name: Pull Git Repo with Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Generate version
|
||||
run: |
|
||||
VERSION=$(date +%Y%d%m_%H%M)
|
||||
GIT_SHA=$(git rev-parse --short HEAD)
|
||||
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "GIT_SHA=$GIT_SHA" >> $GITHUB_ENV
|
||||
|
||||
echo "Version: $VERSION Commit:$GIT_SHA" > public/VERSION
|
||||
|
||||
- name: Login to registry
|
||||
run: |
|
||||
echo "${{ secrets.MAAL_REGISTRY_PASSWORD }}" | docker login registry.ma-al.pl \
|
||||
-u "${{ secrets.MAAL_REGISTRY_USER }}" \
|
||||
--password-stdin
|
||||
|
||||
- name: Build application image
|
||||
run: |
|
||||
cat <<EOF > temp.Dockerfile
|
||||
FROM oven/bun:1
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN bun install --frozen-lockfile
|
||||
USER bun
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["bun", "./src/server.js"]
|
||||
EOF
|
||||
|
||||
docker build \
|
||||
-t "${{ env.REGISTRY_ADDRESS }}/${{ env.DOCKER_APP_NAME }}:${{ env.VERSION }}" \
|
||||
-t "${{ env.REGISTRY_ADDRESS }}/${{ env.DOCKER_APP_NAME }}:latest" \
|
||||
-f temp.Dockerfile .
|
||||
|
||||
rm temp.Dockerfile
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
docker push "${{ env.REGISTRY_ADDRESS }}/${{ env.DOCKER_APP_NAME }}:${{ env.VERSION }}"
|
||||
docker push "${{ env.REGISTRY_ADDRESS }}/${{ env.DOCKER_APP_NAME }}:latest"
|
||||
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ env.MAAL_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan 192.168.220.30 >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Execute Remote Command
|
||||
run: |
|
||||
echo "Deploying version: ${{ env.VERSION }}"
|
||||
ssh docker@192.168.220.30 \
|
||||
"docker compose -f /volume/docker/sys/portainer/compose/71/docker-compose.yml -p mwingz_ma-al_pl pull && \
|
||||
docker compose -f /volume/docker/sys/portainer/compose/71/docker-compose.yml -p mwingz_ma-al_pl up -d"
|
||||
|
||||
+52
-25
@@ -61,32 +61,59 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- API documentation -->
|
||||
<div class="card mt-3">
|
||||
<div class="card-body d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<h6 class="fw-semibold mb-1"><i class="bi bi-book me-1"></i>API Documentation</h6>
|
||||
<p class="text-muted small mb-0">OpenAPI reference for the Check List backend endpoints.</p>
|
||||
</div>
|
||||
<a href="/api-docs" target="_blank" class="btn btn-outline-secondary btn-sm">View docs</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- API documentation -->
|
||||
<div class="card mt-3">
|
||||
<div class="card-body d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<h6 class="fw-semibold mb-1"><i class="bi bi-book me-1"></i>API Documentation</h6>
|
||||
<p class="text-muted small mb-0">OpenAPI reference for the Check List backend endpoints.</p>
|
||||
</div>
|
||||
<a href="/api-docs" target="_blank" class="btn btn-outline-secondary btn-sm">View docs</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Version info -->
|
||||
<div class="card mt-3">
|
||||
<div class="card-body">
|
||||
<div id="versionInfo" class="text-center text-muted small">
|
||||
Loading version...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
// Cleanup button
|
||||
document.getElementById('cleanupBtn').addEventListener('click', () => {
|
||||
if (!confirm('This will remove ALL application data (cached data, settings). Continue?')) return;
|
||||
localStorage.removeItem('user_language');
|
||||
// Clear IndexedDB
|
||||
indexedDB.databases().then(dbs => {
|
||||
dbs.forEach(db => indexedDB.deleteDatabase(db.name));
|
||||
}).catch(() => {});
|
||||
alert('All data cleared. Page will reload.');
|
||||
location.reload();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
(function() {
|
||||
// Cleanup button
|
||||
document.getElementById('cleanupBtn').addEventListener('click', () => {
|
||||
if (!confirm('This will remove ALL application data (cached data, settings). Continue?')) return;
|
||||
localStorage.removeItem('user_language');
|
||||
// Clear IndexedDB
|
||||
indexedDB.databases().then(dbs => {
|
||||
dbs.forEach(db => indexedDB.deleteDatabase(db.name));
|
||||
}).catch(() => {});
|
||||
alert('All data cleared. Page will reload.');
|
||||
location.reload();
|
||||
});
|
||||
})();
|
||||
|
||||
// Fetch and display version
|
||||
fetch('/VERSION')
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then(versionText => {
|
||||
const versionInfo = document.getElementById('versionInfo');
|
||||
versionInfo.textContent = versionText.trim() || 'Version not available';
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Could not load version:', error);
|
||||
const versionInfo = document.getElementById('versionInfo');
|
||||
versionInfo.textContent = 'Version not available';
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user