mirror of
https://github.com/unraid/api.git
synced 2026-01-02 22:50:02 -06:00
182 lines
5.6 KiB
YAML
182 lines
5.6 KiB
YAML
name: Pull Request
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- api/**
|
|
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: true
|
|
- name: Reconfigure git to use HTTP authenti:cation
|
|
run: >
|
|
git config --global url."https://github.com/".insteadOf
|
|
ssh://git@github.com/
|
|
# Login to ECR
|
|
- name: Configure AWS Credentials
|
|
uses: aws-actions/configure-aws-credentials@v2
|
|
with:
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
|
|
aws-region: "us-west-2"
|
|
- name: Amazon ECR "Login" Action for GitHub Actions
|
|
id: login-ecr
|
|
uses: aws-actions/amazon-ecr-login@v1
|
|
- name: Build Docker Compose
|
|
working-directory: api
|
|
run: |
|
|
docker-compose build builder
|
|
|
|
- name: Tag and push
|
|
env:
|
|
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
|
run: |
|
|
|
|
git_hash=$(git rev-parse --short "$GITHUB_SHA")
|
|
builder_repo_name="$REGISTRY/unraid/api-builder"
|
|
builder_container_tag="$git_hash"
|
|
docker tag unraid-api:builder "$builder_repo_name"/api-builder:"$builder_container_tag"
|
|
docker push "$builder_repo_name"/api-builder:"$builder_container_tag"
|
|
|
|
lint-api:
|
|
needs: [build]
|
|
continue-on-error: true
|
|
defaults:
|
|
run:
|
|
working-directory: api
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: builder
|
|
path: /tmp
|
|
- name: Load image
|
|
run: |
|
|
docker load --input /tmp/builder.tar
|
|
- name: Lint
|
|
run: |
|
|
docker run unraid-api:builder npm run lint
|
|
|
|
test-api:
|
|
needs: [build]
|
|
defaults:
|
|
run:
|
|
working-directory: api
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: builder
|
|
path: /tmp
|
|
- name: Load image
|
|
run: |
|
|
docker load --input /tmp/builder.tar
|
|
- name: Test
|
|
run: |
|
|
docker run unraid-api:builder npm run coverage
|
|
|
|
|
|
build-api:
|
|
needs: [build]
|
|
defaults:
|
|
run:
|
|
working-directory: api
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
API_VERSION: ${{ steps.build-pack-binary.outputs.API_VERSION }}
|
|
API_MD5: ${{ steps.set-hashes.outputs.API_MD5 }}
|
|
API_SHA256: ${{ steps.set-hashes.outputs.API_SHA256 }}
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Download artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: build
|
|
path: /tmp
|
|
- name: Load image
|
|
run: |
|
|
docker load --input /tmp/builder.tar
|
|
|
|
- name: Run Docker Compose
|
|
run: docker run builder npm run build-pkg
|
|
|
|
- name: Set Hashes
|
|
id: set-hashes
|
|
run: |
|
|
API_MD5=$(md5sum ${{ github.workspace }}/api/deploy/release/*.tgz | awk '{ print $1 }')
|
|
API_SHA256=$(sha256sum ${{ github.workspace }}/api/deploy/release/*.tgz | awk '{ print $1 }')
|
|
echo "::set-output name=API_MD5::${API_MD5}"
|
|
echo "::set-output name=API_SHA256::${API_SHA256}"
|
|
|
|
- name: Upload tgz to Github artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: unraid-api
|
|
path: ${{ github.workspace }}/api/deploy/release/*.tgz
|
|
|
|
- name: Parse Changelog
|
|
id: changelog
|
|
uses: ocavue/changelog-parser-action@v1
|
|
with:
|
|
removeMarkdown: false
|
|
filePath: "./api/CHANGELOG.md"
|
|
|
|
- name: View release notes
|
|
run: |
|
|
escapedNotes=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"${{steps.changelog.outputs.latestBody}}")
|
|
echo "${escapedNotes}"
|
|
build-plugin:
|
|
defaults:
|
|
run:
|
|
working-directory: plugin
|
|
runs-on: ubuntu-latest
|
|
needs: [lint-api, test-api, build-api]
|
|
steps:
|
|
- name: Set Timezone
|
|
uses: szenius/set-timezone@v1.2
|
|
with:
|
|
timezoneLinux: "America/Los_Angeles"
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
- name: Build Plugin
|
|
run: |
|
|
cd source/dynamix.unraid.net
|
|
export API_VERSION=${{needs.build-api.outputs.API_VERSION}}
|
|
export API_MD5=${{needs.build-api.outputs.API_MD5}}
|
|
export API_SHA256=${{needs.build-api.outputs.API_SHA256}}
|
|
bash ./pkg_build.sh s
|
|
bash ./pkg_build.sh p
|
|
- name: Create release notes
|
|
run: |
|
|
LAST_RELEASE=$(git tag --list --sort=v:refname | tail -1)
|
|
echo ${LAST_RELEASE}
|
|
RELEASE_NOTES=$(git log "$LAST_RELEASE...HEAD" --pretty=format:"- %s [\`%h\`](http://github.com/$GITHUB_REPOSITORY/commit/%H)" --reverse)
|
|
echo "${RELEASE_NOTES}"
|
|
# escapedNotes=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"${RELEASE_NOTES}")
|
|
# sed -i -z -E "s/<CHANGES>(.*)<\/CHANGES>/<CHANGES>\n${escapedNotes}\n<\/CHANGES>/g" "plugins/dynamix.unraid.net.staging.plg"
|
|
- name: Upload binary txz and plg to Github artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: connect-files
|
|
path: |
|
|
${{ github.workspace }}/plugin/archive/*.txz
|
|
${{ github.workspace }}/plugin/plugins/*.plg
|
|
retention-days: 5
|
|
if-no-files-found: error
|