Compare commits
2 Commits
d52b203eb7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 29fb48906a | |||
| 5b31a1b953 |
@@ -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"
|
||||||
|
|
||||||
@@ -71,6 +71,15 @@
|
|||||||
<a href="/api-docs" target="_blank" class="btn btn-outline-secondary btn-sm">View docs</a>
|
<a href="/api-docs" target="_blank" class="btn btn-outline-secondary btn-sm">View docs</a>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</main>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -87,6 +96,24 @@
|
|||||||
location.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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user