Skip to content

Commit

Permalink
Update devcontainer pr ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Dec 1, 2023
1 parent 4979471 commit a8ddb88
Showing 1 changed file with 55 additions and 55 deletions.
110 changes: 55 additions & 55 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a8ddb88

Please sign in to comment.