-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR migrated the codebase to run in Rust. ## Why? Because I don't want to get _rusty_ (🥁) and this action is small enough to test how the GitHub actions environment works in Rust. This project uses [actions-github](https://crates.io/crates/actions-github) as it's main dependency to obtain the metadata.
- Loading branch information
Showing
14 changed files
with
1,678 additions
and
479 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,102 +7,71 @@ on: | |
|
||
env: | ||
IMAGE_NAME: action | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
test-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3.3.0 | ||
- uses: actions/checkout@v4 | ||
- name: Check that the image builds | ||
run: docker build . --file Dockerfile | ||
|
||
test-versions: | ||
compare-versions: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.verification.outputs.VERSION }} | ||
exists: ${{ steps.checkTag.outputs.exists }} | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Extract package.json version | ||
- uses: actions/checkout@v4 | ||
- run: pip install toml-cli | ||
- name: Extract crate version | ||
id: package_version | ||
run: echo "VERSION=$(jq '.version' -r package.json)" >> $GITHUB_OUTPUT | ||
- name: Extract action.yml version | ||
uses: mikefarah/yq@master | ||
id: action_image | ||
with: | ||
cmd: yq '.runs.image' 'action.yml' | ||
- name: Parse action.yml version | ||
id: action_version | ||
run: | | ||
echo "IMAGE_VERSION=$(echo $IMAGE_URL | cut -d: -f3)" >> $GITHUB_OUTPUT | ||
env: | ||
IMAGE_URL: ${{ steps.action_image.outputs.result }} | ||
run: echo "VERSION=$(toml get --toml-path Cargo.toml package.version)" >> $GITHUB_OUTPUT | ||
# Compare that the versions contain the same name | ||
- name: Compare versions | ||
run: | | ||
echo "Verifying that $IMAGE_VERSION from action.yml is the same as $PACKAGE_VERSION from package.json" | ||
[[ $IMAGE_VERSION == $PACKAGE_VERSION ]] | ||
env: | ||
IMAGE_VERSION: ${{ steps.action_version.outputs.IMAGE_VERSION }} | ||
PACKAGE_VERSION: ${{ steps.package_version.outputs.VERSION }} | ||
id: verification | ||
uses: Bullrich/compare-version-on-action@main | ||
with: | ||
version: ${{ steps.package_version.outputs.VERSION }} | ||
# Verifies if there is a tag with that version number | ||
- uses: mukunku/[email protected] | ||
if: steps.verification.outputs.VERSION | ||
id: checkTag | ||
with: | ||
tag: v${{ steps.package_version.outputs.VERSION }} | ||
|
||
tag: | ||
if: github.event_name == 'push' | ||
needs: [test-image, test-versions] | ||
publish: | ||
if: github.event_name == 'push' && needs.compare-versions.outputs.exists == 'false' | ||
needs: [test-image, compare-versions] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
outputs: | ||
tagcreated: ${{ steps.autotag.outputs.tagcreated }} | ||
tagname: ${{ steps.autotag.outputs.tagname }} | ||
packages: write | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/checkout@v4 | ||
- name: Tag version and create release | ||
run: gh release create $VERSION --generate-notes | ||
env: | ||
VERSION: v${{ needs.compare-versions.outputs.version }} | ||
GH_TOKEN: ${{ github.token }} | ||
- name: Log in to the Container registry | ||
uses: docker/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
- uses: butlerlogic/action-autotag@stable | ||
id: autotag | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
head_branch: master | ||
tag_prefix: "v" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Changelog | ||
uses: Bullrich/[email protected] | ||
id: Changelog | ||
env: | ||
REPO: ${{ github.repository }} | ||
- name: Create Release | ||
if: steps.autotag.outputs.tagname != '' | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }} | ||
tags: ${{ needs.compare-versions.outputs.version }} | ||
- uses: actions/checkout@v4 | ||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
tag_name: ${{ steps.autotag.outputs.tagname }} | ||
release_name: Release ${{ steps.autotag.outputs.tagname }} | ||
body: | | ||
${{ steps.Changelog.outputs.changelog }} | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
needs: [tag] | ||
if: needs.tag.outputs.tagname != '' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build image | ||
run: docker build . --file Dockerfile --tag $IMAGE_NAME | ||
- name: Log into registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | ||
- name: Push image | ||
run: | | ||
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
[[ ! -z $TAG ]] && VERSION=$(echo $TAG | sed -e 's/^v//') | ||
# Use Docker `latest` tag convention | ||
[ "$VERSION" == "main" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION | ||
env: | ||
TAG: ${{ needs.tag.outputs.tagname }} | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Find team members | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
get-team: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch team data | ||
# We add the id to access to this step outputs | ||
id: teams | ||
uses: paritytech/list-team-members@main | ||
with: | ||
ACCESS_TOKEN: ${{ secrets.READ_ORG_PAT }} | ||
team: opstooling | ||
# optional, in case that it searches on a different organization | ||
organization: paritytech | ||
# example showing how to use the content | ||
- name: Show data | ||
run: | | ||
echo "The users are $USERNAMES" | ||
echo "Data: $DATA" | ||
env: | ||
USERNAMES: ${{ steps.teams.outputs.usernames }}" | ||
# a json object | ||
DATA: ${{ steps.teams.outputs.data }}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
name: Continuous integration | ||
|
||
jobs: | ||
test: | ||
name: "Test" | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
cmd: | ||
- check | ||
- fmt --all -- --check | ||
- clippy -- -D warnings | ||
- doc | ||
- test | ||
- build --release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- run: cargo ${{ matrix.cmd }} | ||
conclude: | ||
runs-on: ubuntu-latest | ||
name: All tests passed | ||
needs: [test] | ||
steps: | ||
- run: echo '### Good job! All the tests passed 🚀' >> $GITHUB_STEP_SUMMARY |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,18 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# TernJS port file | ||
.tern-port | ||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb |
Oops, something went wrong.