#minor various command additions and improvements, added second scrip… #116
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Image & Deploy | |
on: | |
push: | |
branches: | |
- main | |
# Ignore changes in docs folder | |
paths-ignore: | |
- 'docs/**' | |
concurrency: cd | |
jobs: | |
build: | |
# runs-on: self-hosted | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write | |
if: "!contains(github.event.head_commit.message, '#skip-ci')" | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Install Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Dry incremement patch version | |
id: tag-dry-run | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEFAULT_BUMP: none | |
WITH_V: true | |
DRY_RUN: true | |
- name: Set version for later | |
run: | | |
echo "Increnting version with '${{ steps.tag-dry-run.outputs.part }}' to '${{ steps.tag-dry-run.outputs.new_tag }}' from '${{ steps.tag-dry-run.outputs.tag }}'" | |
tag=${{ steps.tag-dry-run.outputs.new_tag }} | |
version=$(echo "$tag" | cut -b 2-) | |
echo "version=$version" >> $GITHUB_ENV | |
- name: Set npm version | |
uses: reedyuk/[email protected] | |
with: | |
version: ${{ env.version }} | |
- name: Docker metadata | |
id: metadata | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository_owner }}/discord-bot | |
tags: | | |
type=semver,pattern={{major}},value=${{ env.version }} | |
type=semver,pattern={{major}}.{{minor}},value=${{ env.version }} | |
- name: Set up Docker Context for Buildx | |
id: buildx-context | |
run: | | |
docker context create builders | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
endpoint: builders | |
- name: Log in to GitHub Container Registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Increment patch version | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
DEFAULT_BUMP: none | |
deploy: | |
# runs-on: self-hosted | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
if: "!contains(github.event.head_commit.message, '#skip-ci')" | |
needs: ['build'] # always run after build step | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- run: flyctl deploy --remote-only | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
# - uses: steebchen/[email protected] | |
# with: | |
# config: ${{ secrets.KUBECONFIG }} | |
# command: rollout restart deployment/helldivers2-bot-deployment -n=helldivers2 |