diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 34e2851..a4cf51d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,6 +12,7 @@ } }, "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {} + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} } } diff --git a/.github/workflows/publish-devcontainer.yml b/.github/workflows/publish-devcontainer.yml new file mode 100644 index 0000000..6fdda17 --- /dev/null +++ b/.github/workflows/publish-devcontainer.yml @@ -0,0 +1,29 @@ +name: Build and push the devcontainer + +on: + push: + branches: + - main + +jobs: + build-and-publish-devcontainer: + runs-on: ubuntu-latest + steps: + + - name: Checkout (GitHub) + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and publish Dev Container + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/viginum-fr/d3lta + cacheFrom: ghcr.io/viginum-fr/d3lta diff --git a/.github/workflows/test-devcontainer.yml b/.github/workflows/test-devcontainer.yml new file mode 100644 index 0000000..45a6b61 --- /dev/null +++ b/.github/workflows/test-devcontainer.yml @@ -0,0 +1,31 @@ +name: Test building the devcontainer + +on: # test on any PRs and main branch changes + pull_request: + push: + branches: + - main + +jobs: + build-devcontainer: + name: Test building the dev container + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build the dev container + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/viginum-fr/d3lta + cacheFrom: ghcr.io/viginum-fr/d3lta + push: never diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..97e73cc --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +MAKEFLAGS += --no-print-directory + +.PHONY: _login-to-github +.PHONY: _trigger-act-job-with-github-token + +# prefixed with _ to prevent these commands from showing up in make's autocomplete +_login-to-github: + gh auth login -s $(SCOPES) +_trigger-act-job-with-github-token: + @act -j ${JOB} -s GITHUB_TOKEN="$$(gh auth token)" + +act-login-to-github-and-%: + @make _login-to-github SCOPES=${SCOPES} + @make act-$* + +act-login-to-github-and-build-devcontainer: SCOPES=read:packages +act-login-to-github-and-build-and-publish-devcontainer: SCOPES=write:packages + +act-%: + @make _trigger-act-job-with-github-token JOB="$*" + +# ensures these commands are displayed in make's autocomplete +act-build-devcontainer : +act-build-and-publish-devcontainer :