ovlach_frontend/.gitea/workflows/release_docker.yaml

84 lines
4.2 KiB
YAML
Raw Normal View History

2023-12-03 14:46:05 +00:00
name: release
run-name: release
on:
push:
branches:
- master
jobs:
tests:
2023-12-03 18:22:18 +00:00
name: tests
runs-on: ubuntu-latest
steps:
- uses: https://github.com/actions/checkout.git@v4
- name: Hash of Cargo.lock
id: get-hash
run: echo "::set-output name=hash::$(md5sum Cargo.lock | awk '{ print $1; }')"
- uses: https://gitea.com/wolfogre/cache/restore@v3
id: cache
with:
key: "${{github.repository}}-cache-cargo-clippy-v4-${{ steps.get-hash.outputs.hash }}"
path: |
.cache
target
restore-keys: ${{github.repository}}-cache-cargo-clippy-v4
2023-12-03 18:22:18 +00:00
- name: tests
2023-12-09 10:49:45 +00:00
uses: nanobyte-public/rust-action@v3
2023-12-03 18:22:18 +00:00
with:
args: |
2023-12-09 10:49:45 +00:00
CARGO_HOME=./.cache cargo-nan \"${{secrets.deployment_package}}\" cargo clippy -- -Dwarnings && \
CARGO_HOME=./.cache cargo-nan \"${{secrets.deployment_package}}\" cargo clippy --tests -- -Dwarnings && \
CARGO_HOME=./.cache cargo-nan \"${{secrets.deployment_package}}\" cargo test
- uses: https://gitea.com/wolfogre/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
path: |
.cache
target
key: "${{github.repository}}-cache-cargo-clippy-v4-${{ steps.get-hash.outputs.hash }}"
2023-12-08 23:56:30 +00:00
docker:
name: docker
2023-12-03 14:46:05 +00:00
runs-on: ubuntu-latest
2023-12-09 11:01:41 +00:00
needs: tests # require tests to pass before deploy runs
2023-12-03 14:46:05 +00:00
container:
image: ovlach/docker-gitea:v0.0.2-alpha
steps:
- uses: https://github.com/actions/checkout.git@v4
- name: Login to git.nanobyte.cz
uses: https://github.com/docker/login-action@v3
with:
username: ${{ secrets.DEPLOYMENT_PACKAGE }}
password: ${{ secrets.DEPLOYMENT_PACKAGE }}
registry: git.nanobyte.cz
- name: Get short hash from git repository
id: git
run: echo "::set-output name=short_hash::$(git rev-parse --short HEAD)"
- name: Build and push docker
run: |
2023-12-09 11:13:29 +00:00
docker build . -t git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_frontend:${{steps.git.outputs.short_hash}} --build-arg GITEA_TOKEN="${{secrets.DEPLOYMENT_PACKAGE}}" && \
2023-12-03 18:22:18 +00:00
docker push git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_frontend:${{steps.git.outputs.short_hash}}
2023-12-08 23:56:30 +00:00
stage_deployment:
name: stage-deployment
runs-on: ubuntu-latest
2023-12-09 11:01:41 +00:00
needs: [docker, tests] # require tests to pass before deploy runs
2023-12-08 23:56:30 +00:00
steps:
- name: Install kustomize
run: |
2023-12-09 01:19:29 +00:00
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.3.0/kustomize_v5.3.0_linux_amd64.tar.gz -o kustomize.tar.gz && tar -xzf kustomize.tar.gz
2023-12-08 23:56:30 +00:00
- uses: https://github.com/actions/checkout.git@v4
with:
2023-12-09 00:34:05 +00:00
ssh-key: '${{ secrets.VLACH_XYZ_DEPLOY }}'
2023-12-08 23:56:30 +00:00
path: 'vlach_xyz_deploy'
2023-12-09 00:34:05 +00:00
repository: 'ovlach/vlach_xyz'
2023-12-08 23:56:30 +00:00
ref: 'master'
2023-12-09 00:34:05 +00:00
github-server-url: 'ssh://git.nanobyte.cz'
ssh-known-hosts: 'git.nanobyte.cz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC3senpFPTYk75y73d1xL4XEDBe5AcLJ+GLEA+XTMpMiLsociwUeJZCJZoRUsZBH1bSvlgT23wlHtGJvDARygCBX/rZKKIb0KdD5qYgbtCzdmyg1Aw6+RNbgsOZuuDqh1HCLftj6PZWKXfEyp1rLjVCJEBmK2+iC54VjGTrm/0D3Mi1Tzpbmz0U+SqiZpNmC4GJu3riyxcXBrySsEZjWFcrUGSfVW9/MzzNk6relemGrkvBFDh6+lcx5bvPi3wamm0dlS+ySB9GhkGMukjCHHGLleRRZB3hf8ClbiMrod0KXwG1RQzqBIn3or4AUrl2ExIeA+olBTGIooy1sf/s8qBSGytYwUR1wbkMa9SIPWxIyioQY2uPu8Jg2qUYyZCJLNMeCVne5QGfxcDPm468pkkKOHVDqsVmhzRvcLuadpLHffZRg9Ds8LWSpIZh/OSWUkeavP0kSEN+vC4j/pFepYId3GJrEv/FN8KvdxKndkH2WyK2JAMcbTQAq3LiUgApuSuY1717VYNEhkEJ7u4NNmZhkW7WpTU75TCwMqrR77/eHO3ou5U7LEAKE4ujXrRX6HDgiRpg4psnI48hoJ/K50DYCL9CUAYcXLXjWhfmYUaN/1FYWS6cNpaTcwqOsdpYW4yfzqzIPLxe4GbIcEPinkywr7InwivyDIsPUYbXE9KBEw=='
2023-12-09 11:29:53 +00:00
- uses: https://github.com/actions/checkout.git@v4
2023-12-09 11:23:29 +00:00
- name: Get short hash from git repository
id: git
run: echo "::set-output name=short_hash::$(git rev-parse --short HEAD)"
2023-12-09 00:34:05 +00:00
- name: configure git
run: git config --global user.email "gitea-bot@nanobyte.cz" && git config --global user.name "Gitea Bot"
2023-12-08 23:56:30 +00:00
- name: Update images
run: |
2023-12-09 00:34:05 +00:00
cd vlach_xyz_deploy && cd kubernetes/staging/ && ../../../kustomize edit set image web=git.nanobyte.cz/$GITHUB_REPOSITORY_OWNER/ovlach_frontend:${{steps.git.outputs.short_hash}} && git add . && git commit -m "upgrade ovlach_frontend -> ${{steps.git.outputs.short_hash}}" && git push origin master