This commit is contained in:
@@ -6,9 +6,9 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: git.sebse.de
|
IMAGE: git.sebse.de/${{ github.repository }}
|
||||||
IMAGE: git.sebse.de/sebse/factorio-signal-exporter
|
IMAGE_MIGRATE: git.sebse.de/${{ github.repository }}-migrate
|
||||||
IMAGE_MIGRATE: git.sebse.de/sebse/factorio-signal-exporter-migrate
|
CHART_PATH: web/charts/factorio-signal-exporter
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -18,100 +18,41 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Helm
|
- name: Set SHORT_SHA
|
||||||
uses: azure/setup-helm@v4
|
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Log in to Gitea Container Registry
|
- name: Docker login
|
||||||
uses: docker/login-action@v3
|
uses: sebse/actions/docker-login@main
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Extract metadata (app)
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.IMAGE }}
|
|
||||||
tags: |
|
|
||||||
type=sha,prefix=,format=short
|
|
||||||
type=raw,value=latest
|
|
||||||
|
|
||||||
- name: Build and push app
|
- name: Build and push app
|
||||||
uses: docker/build-push-action@v5
|
uses: sebse/actions/docker-build-push@main
|
||||||
with:
|
with:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
context: ./web
|
context: ./web
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=registry,ref=${{ env.IMAGE }}:latest
|
|
||||||
cache-to: type=inline
|
|
||||||
|
|
||||||
- name: Extract metadata (migrate)
|
|
||||||
id: meta-migrate
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.IMAGE_MIGRATE }}
|
|
||||||
tags: |
|
|
||||||
type=sha,prefix=,format=short
|
|
||||||
type=raw,value=latest
|
|
||||||
|
|
||||||
- name: Build and push migrate
|
- name: Build and push migrate
|
||||||
uses: docker/build-push-action@v5
|
uses: sebse/actions/docker-build-push@main
|
||||||
with:
|
with:
|
||||||
|
image: ${{ env.IMAGE_MIGRATE }}
|
||||||
context: ./web
|
context: ./web
|
||||||
file: ./web/Dockerfile.migrate
|
dockerfile: ./web/Dockerfile.migrate
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta-migrate.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-migrate.outputs.labels }}
|
|
||||||
cache-from: type=registry,ref=${{ env.IMAGE_MIGRATE }}:latest
|
|
||||||
cache-to: type=inline
|
|
||||||
|
|
||||||
- name: Inject image tags into chart values
|
- name: Package and push helm chart
|
||||||
run: |
|
uses: sebse/actions/helm-package-push@main
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
with:
|
||||||
sed -i "s|^\(\s*tag:\).*|\1 ${SHORT_SHA}|" web/charts/factorio-signal-exporter/values.yaml
|
chart-path: ${{ env.CHART_PATH }}
|
||||||
|
version: 0.0.0-${{ env.SHORT_SHA }}
|
||||||
- name: Package Helm chart (SHA)
|
app-version: ${{ env.SHORT_SHA }}
|
||||||
run: |
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
helm package web/charts/factorio-signal-exporter \
|
|
||||||
--version "0.0.0-${SHORT_SHA}" \
|
|
||||||
--app-version "${SHORT_SHA}"
|
|
||||||
|
|
||||||
- name: Push Helm chart (SHA) to Gitea
|
|
||||||
run: |
|
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
|
||||||
curl -u ${{ secrets.REGISTRY_USERNAME }}:${{ secrets.REGISTRY_TOKEN }} \
|
|
||||||
-X POST \
|
|
||||||
https://${{ env.REGISTRY }}/api/packages/sebse/helm/api/charts \
|
|
||||||
-F "chart=@factorio-signal-exporter-0.0.0-${SHORT_SHA}.tgz" \
|
|
||||||
--fail-with-body
|
|
||||||
|
|
||||||
- name: Package Helm chart (latest)
|
|
||||||
run: |
|
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
|
||||||
helm package web/charts/factorio-signal-exporter \
|
|
||||||
--version "0.0.0-latest" \
|
|
||||||
--app-version "${SHORT_SHA}"
|
|
||||||
|
|
||||||
- name: Push Helm chart (latest) to Gitea
|
|
||||||
run: |
|
|
||||||
curl -u ${{ secrets.REGISTRY_USERNAME }}:${{ secrets.REGISTRY_TOKEN }} \
|
|
||||||
-X POST \
|
|
||||||
https://${{ env.REGISTRY }}/api/packages/sebse/helm/api/charts \
|
|
||||||
-F "chart=@factorio-signal-exporter-0.0.0-latest.tgz" \
|
|
||||||
--fail-with-body
|
|
||||||
|
|
||||||
- name: Deploy to prod
|
- name: Deploy to prod
|
||||||
run: |
|
uses: sebse/actions/helm-deploy@main
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
with:
|
||||||
mkdir -p ~/.ssh
|
app: factorio-signal-exporter
|
||||||
echo "${{ secrets.HELMBOT_SSH_KEY }}" > ~/.ssh/helmbot_deploy
|
profile: prod
|
||||||
chmod 600 ~/.ssh/helmbot_deploy
|
version: 0.0.0-${{ env.SHORT_SHA }}
|
||||||
ssh -i ~/.ssh/helmbot_deploy \
|
ssh-key: ${{ secrets.HELMBOT_SSH_KEY }}
|
||||||
-o StrictHostKeyChecking=no \
|
|
||||||
-p 1234 \
|
|
||||||
helmbot@84.247.134.31 \
|
|
||||||
" -s factorio-signal-exporter -p prod -v 0.0.0-${SHORT_SHA}"
|
|
||||||
rm ~/.ssh/helmbot_deploy
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user