Skip to content

Commit

Permalink
update registries and improve GHA (#33)
Browse files Browse the repository at this point in the history
* update registries and improve GHA

Builds all PRs and pushes to main, making PRs :devel and pushes to main :latest. The built PR image tags will be commented on the PR

* make sha in its own step

* this is PS silly

* more attempts

* more attempts

* more attempts

* more attempts

* more attempts

* more attempts

* more attempts

* more attempts

* more attempts

* correct PR comment and Dockerfile labels

* add tag for pr comment

* remove template properly

* moved non-sensitive secrets to variables

* moved non-sensitive secrets to variables
  • Loading branch information
PipeItToDevNull authored Dec 8, 2024
1 parent 5a05481 commit 46c68c8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/azure-swa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
- name: Create .env file
uses: SpicyPizza/create-envfile@v1
with:
envkey_REACT_APP_SITE_NAME: ${{ secrets.REACT_APP_SITE_NAME }}
envkey_REACT_APP_REPO_URL: ${{ secrets.REACT_APP_REPO_URL }}
envkey_REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }}
envkey_REACT_APP_SITE_NAME: ${{ vars.REACT_APP_SITE_NAME }}
envkey_REACT_APP_REPO_URL: ${{ vars.REACT_APP_REPO_URL }}
envkey_REACT_APP_API_URL: ${{ vars.REACT_APP_API_URL }}
directory: swa

- name: Build And Deploy
Expand Down
50 changes: 45 additions & 5 deletions .github/workflows/bsod-api-container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
REPO: pipeittodevnull
IMAGE: bsod-api
REPO: r-techsupport
IMAGE: webdbg-api

jobs:
build_and_push:
runs-on: windows-2022
permissions:
contents: write
pull-requests: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

Expand All @@ -31,5 +36,40 @@ jobs:

- name: Build and push
run: |
docker build -t ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE}}:latest api/
docker push ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE}}:latest
$SHA = "${{ github.sha }}"[0..6] -join ''
if ("${{ github.ref }}" -eq 'refs/heads/main') {
$TAG = 'latest'
} else {
$TAG = 'devel'
}
echo "SHA=$SHA" >> $env:GITHUB_ENV
echo "TAG=$TAG" >> $env:GITHUB_ENV
Write-Host "Using tag: $TAG"
Write-Host "Using SHA: $SHA"
docker build -t `
${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}:$TAG `
-t ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}:$SHA `
api/
docker push ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}:$TAG
docker push ${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}:$SHA
- name: Log out from the Container registry
run: docker logout ${{ env.REGISTRY }}

- name: Comment on the PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const tagImage = '${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}:${{ env.TAG }}';
const shaImage = '${{ env.REGISTRY }}/${{ env.REPO }}/${{ env.IMAGE }}:${{ env.SHA }}';
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `Docker images have been built and pushed:\n- \`${tagImage}\`\n- \`${shaImage}\``
});
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ EXPOSE 3000
# Start the application
CMD ["node", "api.js"]

LABEL org.opencontainers.image.source https://github.com/PipeItToDevNull/bsod-api
LABEL org.opencontainers.image.source https://github.com/r-Techsupport/WebDBG
LABEL org.opencontainers.image.description A BSOD debug API using WinDebug-Container
24 changes: 0 additions & 24 deletions template.json

This file was deleted.

0 comments on commit 46c68c8

Please sign in to comment.