-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
55 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 |
---|---|---|
|
@@ -3,80 +3,80 @@ name: devcontainer | |
on: | ||
push: | ||
paths: | ||
- '.devcontainer/**' | ||
- '.github/workflows/devcontainer.yml' | ||
- '!.devcontainer/devcontainer.json' | ||
- ".devcontainer/**" | ||
- ".github/workflows/devcontainer.yml" | ||
- "!.devcontainer/devcontainer.json" | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set Docker tag for release event | ||
if: github.event_name == 'release' | ||
run: echo "DOCKER_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | ||
- name: Set Docker tag for release event | ||
if: github.event_name == 'release' | ||
run: echo "DOCKER_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | ||
|
||
- name: Set Docker tag for push event | ||
if: github.event_name == 'push' | ||
run: | | ||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7) | ||
echo "DOCKER_TAG=$SHORT_SHA" >> $GITHUB_ENV | ||
- name: Set Docker tag for push event | ||
if: github.event_name == 'push' | ||
run: | | ||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7) | ||
echo "DOCKER_TAG=$SHORT_SHA" >> $GITHUB_ENV | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
file: .devcontainer/Dockerfile | ||
tags: ghcr.io/${{ github.repository }}-dev:latest,ghcr.io/${{ github.repository }}-dev:${{ env.DOCKER_TAG }} | ||
build-args: | | ||
VARIANT=bullseye | ||
platforms: linux/amd64,linux/arm64 | ||
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-dev:latest | ||
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}-dev:cache | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
file: .devcontainer/Dockerfile | ||
tags: ghcr.io/${{ github.repository }}-dev:latest,ghcr.io/${{ github.repository }}-dev:${{ env.DOCKER_TAG }} | ||
build-args: | | ||
VARIANT=bullseye | ||
platforms: linux/amd64,linux/arm64 | ||
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-dev:latest | ||
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}-dev:cache | ||
|
||
propose-update-pr: | ||
needs: build-and-push | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Update devcontainer.json | ||
run: | | ||
sed -i "s|ghcr.io/dojoengine/dojo-dev:[a-zA-Z0-9._-]*|ghcr.io/dojoengine/dojo-dev:${{ needs.build-and-push.outputs.DOCKER_TAG }}|" .devcontainer/devcontainer.json | ||
- name: Update devcontainer.json | ||
run: | | ||
sed -i "s|ghcr.io/dojoengine/dojo-dev:[a-zA-Z0-9._-]*|ghcr.io/dojoengine/dojo-dev:${{ needs.build-and-push.outputs.DOCKER_TAG }}|" .devcontainer/devcontainer.json | ||
- name: Setup Git credentials | ||
run: | | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
- name: Setup Git credentials | ||
run: | | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
- name: Commit and push changes | ||
run: | | ||
git add .devcontainer/devcontainer.json | ||
git commit -m "Update devcontainer image hash" | ||
git push | ||
- name: Commit and push changes | ||
run: | | ||
git add .devcontainer/devcontainer.json | ||
git commit -m "Update devcontainer image hash: ${{needs.build-and-push.outputs.DOCKER_TAG}}" | ||
git push -b devcontainer-${{needs.build-and-push.outputs.DOCKER_TAG}} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
title: "Update devcontainer image hash" | ||
commit-message: "Update devcontainer image hash" | ||
branch: update-devcontainer-image-hash | ||
base: main | ||
delete-branch: true | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
title: "Update devcontainer image hash: ${{needs.build-and-push.outputs.DOCKER_TAG}}" | ||
commit-message: "Update devcontainer image hash" | ||
branch: update-devcontainer-image-hash | ||
base: main | ||
delete-branch: true |