Skip to content

Update repository structure for new GitHub repository #1

Update repository structure for new GitHub repository

Update repository structure for new GitHub repository #1

Workflow file for this run

name: Build
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: write
packages: write
pull-requests: read
jobs:
commitlint:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch-depth is required
- uses: wagoid/commitlint-github-action@v6
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for pre-commit to be able scan history
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: go install ./...
- name: go-vet
run: go vet -v ./...
- name: go-test
run: go test -v ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
- uses: pre-commit/[email protected]
e2e:
runs-on: ubuntu-latest
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
DISK_IMAGE: docker-ce
DISK_SIZE: "30"
MACHINE_ID: test-${{ github.run_id }}
MACHINE_FOLDER: ${{ github.workspace }}./ssh
MACHINE_TYPE: "cx22"
REGION: "nbg1"
SSH_KEY_PUB: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK2sB1n570BgGJ3+I0Dgzxhlf9ukc+Hp+C/zsIH4J8Xm vscode@df47ba471beb"
SSH_KEY: ${{ secrets.SSH_KEY }}
steps:
- uses: actions/checkout@v4
- uses: hetznercloud/setup-hcloud@v1
- name: Set up SSH keys
run: |
mkdir -p ${MACHINE_FOLDER}
echo ${SSH_KEY_PUB} > ${MACHINE_FOLDER}/sshkey.pub
echo ${SSH_KEY} > ${MACHINE_FOLDER}/sshkey
ls -la ${MACHINE_FOLDER}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go build -o provider .
- name: Create command
run: ./provider create
- name: Run command
env:
COMMAND: hostname
run: ./provider command | grep ${MACHINE_ID}
- name: Stop command
run: ./provider stop
- name: Start command
run: ./provider start
- name: Run command
env:
COMMAND: hostname
run: ./provider command | grep ${MACHINE_ID}
- name: Delete command
run: ./provider delete
# This can fail due to resources failing to detach properly
- name: Ensure destruction
if: ${{ always() }}
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: ./hack/hcloud_destroy.sh
build:
runs-on: ubuntu-latest
outputs:
is_tag: ${{ steps.branch-name.outputs.is_tag }}
env:
# Used to get default HCloud values
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go version
- name: Get branch names
id: branch-name
uses: tj-actions/branch-names@v8
with:
strip_tag_prefix: v
- name: Generate version info
id: version
run: |
if [ "${{ steps.branch-name.outputs.is_tag }}" = "true" ];
then
echo "version=${{ steps.branch-name.outputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "version=development" >> "$GITHUB_OUTPUT"
fi
echo "commit_id=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
echo "gitRepo=github.com/${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT"
- name: Compile binaries
run: ./hack/build.sh
env:
GIT_COMMIT: ${{ steps.version.outputs.commit_id }}
GIT_REPO: ${{ steps.version.outputs.gitRepo }}
RELEASE_VERSION: ${{ steps.version.outputs.version }}
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish:
runs-on: ubuntu-latest
needs:
- build
- commitlint
- e2e
- test
if: needs.build.outputs.is_tag == 'true'
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: actions/setup-node@v4
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.github_release.outputs.changelog }}
files: dist/*